/* design/auth.css */
/* Sign in / Create account (views/auth-page.mjs).

   Design baseline: "Matrix 登录与注册页面优化方案 v1.0" — near-black page, dark
   card 440px wide (32px padding on desktop, 16px page margin on phones), 48px
   inputs and primary button, 8px radius, brand blue as the one primary colour.

   Colours are LITERAL and scoped to .mx-auth, never var(--mx-*): the page must
   read the same under every theme (the t45u toast regression was exactly a
   theme token resolving to dark-on-dark). test/auth-contrast-guard.test.mjs
   parses the --auth-* tokens below and fails the build if a text/background
   pair drops under WCAG AA (4.5:1 text, 3:1 control borders and focus ring).
   If it fails, fix the colours, not the test. */

.mx-auth {
  --auth-bg: #0C1118;
  --auth-card: #151C25;
  --auth-field: #0C1118;
  --auth-ink: #F0F4FA;
  --auth-muted: #A9B6C9;
  --auth-brand: #347CF0;
  --auth-brand-hover: #5B97F5;
  --auth-on-brand: #0C1118;
  --auth-link: #6FA6FF;
  --auth-border: #6B7B92;
  --auth-divider: #38475A;
  --auth-focus: #8DB8FF;
  --auth-error: #FFB4B4;
  --auth-error-border: #FF8A8A;
  --auth-ok: #7DDBA3;
  --auth-secondary: #212B38;
  --auth-secondary-hover: #2B3747;

  box-sizing: border-box;
  max-width: none;
  margin: 0;
  padding: 40px 16px 64px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--auth-bg);
  color: var(--auth-ink);
  font: var(--mx-text-body)/1.55 var(--mx-font-sans);
}
.mx-auth *, .mx-auth *::before, .mx-auth *::after { box-sizing: border-box; }

.mx-auth .mx-auth__card {
  width: 100%;
  max-width: 440px;
  padding: 32px;
  background: var(--auth-card);
  border: 1px solid var(--auth-divider);
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
}

.mx-auth .mx-auth__head { display: block; margin: 0 0 24px; }
.mx-auth .mx-auth__title {
  margin: 0; font-size: var(--mx-text-title); line-height: 1.25; letter-spacing: -.01em; font-weight: 600; color: var(--auth-ink);
}

.mx-auth .mx-auth__form { display: block; margin: 0; }
.mx-auth .mx-auth__field { margin: 0 0 16px; }
.mx-auth .mx-auth__label { display: block; margin: 0 0 6px; font-size: var(--mx-text-control); font-weight: 600; color: var(--auth-ink); }
.mx-auth .mx-auth__control { position: relative; display: flex; gap: 8px; }

.mx-auth .mx-auth__input {
  display: block; flex: 1 1 auto; width: 100%; min-width: 0; height: 48px; margin: 0; padding: 0 14px;
  font: inherit; font-size: var(--mx-text-section); color: var(--auth-ink); background: var(--auth-field);
  border: 1px solid var(--auth-border); border-radius: 8px; outline: none; box-shadow: none;
}
.mx-auth .mx-auth__input::placeholder { color: #8A99AF; -webkit-text-fill-color: #8A99AF; opacity: 1; }
.mx-auth .mx-auth__input:hover { border-color: #8696AD; }
.mx-auth .mx-auth__input:focus-visible,
.mx-auth .mx-auth__input:focus { border-color: var(--auth-focus); box-shadow: 0 0 0 3px rgba(141, 184, 255, .35); }
.mx-auth .mx-auth__input[aria-invalid="true"] { border-color: var(--auth-error-border); }
.mx-auth .mx-auth__input:-webkit-autofill {
  -webkit-text-fill-color: var(--auth-ink); caret-color: var(--auth-ink);
  -webkit-box-shadow: 0 0 0 1000px var(--auth-field) inset;
}
.mx-auth .mx-auth__control--toggle .mx-auth__input { padding-right: 72px; }
.mx-auth .mx-auth__control--send .mx-auth__input { letter-spacing: .18em; font-variant-numeric: tabular-nums; }
.mx-auth .mx-auth__control--send .mx-auth__input::placeholder { letter-spacing: normal; }

.mx-auth .mx-auth__toggle {
  position: absolute; top: 4px; right: 4px; height: 40px; min-width: 56px; padding: 0 12px; margin: 0;
  font: inherit; font-size: var(--mx-text-control); font-weight: 600; color: var(--auth-link); background: transparent;
  border: 0; border-radius: 6px; cursor: pointer;
}
.mx-auth .mx-auth__toggle:hover { background: var(--auth-secondary); }

.mx-auth .mx-auth__send {
  flex: 0 0 auto; min-width: 116px; height: 48px; margin: 0; padding: 0 14px; font: inherit; font-size: var(--mx-text-body); font-weight: 600;
  color: var(--auth-ink); background: var(--auth-secondary); border: 1px solid var(--auth-border); border-radius: 8px; cursor: pointer;
  white-space: nowrap;
}
.mx-auth .mx-auth__send:hover:not(:disabled) { background: var(--auth-secondary-hover); }
.mx-auth .mx-auth__send:disabled { color: var(--auth-muted); cursor: not-allowed; opacity: 1; }

.mx-auth .mx-auth__hint { margin: 6px 0 0; font-size: var(--mx-text-caption); line-height: 1.45; color: var(--auth-muted); }
.mx-auth .mx-auth__error {
  margin: 6px 0 0; font-size: var(--mx-text-control); line-height: 1.4; color: var(--auth-error);
}
.mx-auth .mx-auth__error[hidden] { display: none; }
/* The glyph + words carry the error; the red tint is only reinforcement. */
.mx-auth .mx-auth__error::before { content: "! "; font-weight: 700; }

.mx-auth .mx-auth__aux { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; margin: -4px 0 16px; }
.mx-auth .mx-auth__aux--end { justify-content: flex-end; }
.mx-auth .mx-auth__textlink, .mx-auth .mx-auth__link {
  display: inline; margin: 0; padding: 4px 0; font: inherit; font-size: var(--mx-text-control); font-weight: 600; color: var(--auth-link);
  background: none; border: 0; border-radius: 4px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.mx-auth .mx-auth__textlink:hover, .mx-auth .mx-auth__link:hover { color: #A8C8FF; }

.mx-auth .mx-auth__status { margin: 0 0 16px; font-size: var(--mx-text-control); line-height: 1.45; color: var(--auth-muted); }
.mx-auth .mx-auth__status:empty { display: none; }
.mx-auth .mx-auth__status[data-state="ok"] { color: var(--auth-ok); }
.mx-auth .mx-auth__status[data-state="error"] {
  padding: 10px 12px; color: var(--auth-error); background: rgba(255, 138, 138, .1);
  border: 1px solid var(--auth-error-border); border-radius: 8px;
}
.mx-auth .mx-auth__status[data-state="error"]::before { content: "! "; font-weight: 700; }

.mx-auth .mx-auth__primary,
.mx-auth .mx-auth__google,
.mx-auth .mx-auth__secondary {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; height: 48px; margin: 0; padding: 0 16px;
  font: inherit; font-size: var(--mx-text-section); font-weight: 600; border-radius: 8px; cursor: pointer;
}
.mx-auth .mx-auth__primary { color: var(--auth-on-brand); background: var(--auth-brand); border: 1px solid var(--auth-brand); }
.mx-auth .mx-auth__primary:hover:not(:disabled) { background: var(--auth-brand-hover); border-color: var(--auth-brand-hover); }
.mx-auth .mx-auth__primary:disabled { cursor: progress; opacity: 1; }
.mx-auth .mx-auth__google,
.mx-auth .mx-auth__secondary { color: var(--auth-ink); background: var(--auth-secondary); border: 1px solid var(--auth-border); }
.mx-auth .mx-auth__google:hover:not(:disabled),
.mx-auth .mx-auth__secondary:hover:not(:disabled) { background: var(--auth-secondary-hover); }
.mx-auth .mx-auth__google:disabled { cursor: progress; }
.mx-auth .mx-auth__secondary { margin-top: 10px; }

.mx-auth :is(button, a, input, [tabindex]):focus-visible { outline: 3px solid var(--auth-focus); outline-offset: 2px; }
.mx-auth .mx-auth__input:focus-visible { outline-offset: 0; }

.mx-auth .mx-auth__divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--auth-muted); font-size: var(--mx-text-control); }
.mx-auth .mx-auth__divider::before, .mx-auth .mx-auth__divider::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--auth-divider); }

.mx-auth .mx-auth__switch { margin: 24px 0 0; text-align: center; font-size: var(--mx-text-body); color: var(--auth-muted); }
.mx-auth .mx-auth__switch[hidden] { display: none; }
.mx-auth .mx-auth__legal { margin: 20px 0 0; text-align: center; font-size: var(--mx-text-caption); line-height: 1.5; color: var(--auth-muted); }
.mx-auth .mx-auth__legal-name { color: var(--auth-ink); }
/* Sign-up already names the terms in its consent line; the footer would repeat them. */
.mx-auth__card:has([data-auth-signup-panel]:not([hidden])) [data-auth-legal] { display: none; }

.mx-auth .mx-auth__field--check { margin-bottom: 16px; }
.mx-auth .mx-auth__check { display: flex; align-items: flex-start; gap: 10px; font-size: var(--mx-text-control); line-height: 1.45; color: var(--auth-ink); cursor: pointer; }
.mx-auth .mx-auth__check input {
  flex: 0 0 auto; appearance: none; -webkit-appearance: none; display: grid; place-content: center; width: 20px; height: 20px; margin: 1px 0 0;
  background: var(--auth-field); border: 1px solid var(--auth-border); border-radius: 4px; cursor: pointer;
}
.mx-auth .mx-auth__check input:checked { background: var(--auth-brand); border-color: var(--auth-brand); }
.mx-auth .mx-auth__check input:checked::after { content: ""; width: 5px; height: 10px; margin-top: -2px; border: solid var(--auth-on-brand); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.mx-auth .mx-auth__check input[aria-invalid="true"] { border-color: var(--auth-error-border); }
.mx-auth .mx-auth__empty { padding: 16px; color: var(--auth-muted); border: 1px dashed var(--auth-border); border-radius: 8px; }

/* The sign-in view is one dark surface edge to edge, not a card on a light page. */
html[data-theme] .page:has(> .mx-auth) { background: #0C1118; padding: 0; }

/* Forgot password, in place of the sign-in form (A4). */
.mx-auth [data-auth-root][hidden], .mx-auth [data-auth-head][hidden], .mx-auth [data-auth-forgot-panel][hidden] { display: none; }
.mx-auth .mx-auth__forgot .mx-auth__title { margin: 0; }

@media (max-width: 480px) {
  .mx-auth { padding: 16px 16px 40px; }
  .mx-auth .mx-auth__card { padding: 24px 20px; }
  .mx-auth .mx-auth__control--send { flex-wrap: wrap; }
  .mx-auth .mx-auth__send { min-width: 0; flex: 0 0 auto; }
  .mx-auth .mx-auth__control--send .mx-auth__input { flex: 1 1 120px; }
}
@media (prefers-reduced-motion: no-preference) {
  .mx-auth .mx-auth__input, .mx-auth .mx-auth__primary, .mx-auth .mx-auth__send { transition: border-color .12s, box-shadow .12s, background-color .12s; }
}

/* Main-flows redesign A1/A2 (2026-10-31): Google first, then "or use email";
   the terms are a passive line under Create account (no checkbox, D-F1). */
.mx-auth .mx-auth__google + .mx-auth__divider { margin-top: 20px; }
.mx-auth .mx-auth__terms { margin-top: 12px; text-align: center; }
.mx-auth [data-auth-signup-code-panel][hidden] { display: none; }

/* Standalone pages in the same card (main-flows redesign A4 and F4,
   2026-11-01): /reset-password.html and /join.html load this file and use
   the sign-in card instead of their own light/blue page styles. */
html.mx-auth-html, html.mx-auth-html body { margin: 0; min-height: 100%; background: #0C1118; color-scheme: dark; }
.mx-auth.mx-auth--page { min-height: 100vh; justify-content: center; }
.mx-auth .mx-auth__brand { display: flex; align-items: center; gap: 10px; margin: 0 0 20px; font-weight: 600; color: var(--auth-ink); }
.mx-auth .mx-auth__badge {
  display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--auth-divider); border-radius: 8px;
  background: var(--auth-field); color: var(--auth-link); font: 700 var(--mx-text-control)/1 ui-monospace, monospace;
}
.mx-auth .mx-auth__eyebrow { margin: 0 0 8px; font-size: var(--mx-text-control); color: var(--auth-muted); }
.mx-auth .mx-auth__who {
  display: flex; align-items: center; gap: 12px; margin: 0 0 16px; padding: 10px 12px;
  border: 1px solid var(--auth-divider); border-radius: 8px; font-size: var(--mx-text-body); color: var(--auth-ink);
}
.mx-auth .mx-auth__who > span { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.mx-auth .mx-auth__who small { display: block; font-size: var(--mx-text-control); color: var(--auth-muted); }
.mx-auth .mx-auth__callout {
  margin: 0 0 16px; padding: 12px 14px; font-size: var(--mx-text-body); line-height: 1.5; color: var(--auth-ink);
  background: var(--auth-secondary); border: 1px solid var(--auth-divider); border-radius: 8px;
}
.mx-auth .mx-auth__callout:empty { display: none; }
.mx-auth .mx-auth__notice { display: block; margin-top: 8px; max-height: 140px; overflow: auto; }
.mx-auth .mx-auth__who .mx-auth__link { flex: 0 0 auto; white-space: nowrap; }
.mx-auth .mx-auth__primary + .mx-auth__hint, .mx-auth .msg + .mx-auth__hint { text-align: center; margin-top: 12px; }
.mx-auth a.mx-auth__primary, .mx-auth a.mx-auth__secondary { text-decoration: none; }
.mx-auth .mx-auth__primary[disabled] { cursor: not-allowed; color: var(--auth-muted); background: var(--auth-secondary); border-color: var(--auth-border); }
.mx-auth .msg { display: none; margin: 16px 0 0; font-size: var(--mx-text-control); line-height: 1.45; }
.mx-auth .msg.err { display: block; padding: 10px 12px; color: var(--auth-error); background: rgba(255, 138, 138, .1); border: 1px solid var(--auth-error-border); border-radius: 8px; }
.mx-auth .msg.err::before { content: "! "; font-weight: 700; }
.mx-auth .msg.ok { display: block; color: var(--auth-ok); }
.mx-auth .mx-auth__foot { margin: 20px 0 0; text-align: center; font-size: var(--mx-text-caption); color: var(--auth-muted); }
.mx-auth details.mx-auth__res { margin: 0 0 16px; font-size: var(--mx-text-control); color: var(--auth-muted); }
.mx-auth details.mx-auth__res summary { cursor: pointer; color: var(--auth-ink); }

/* design/task-page-layout.css */
/* Task page layout (founder 2026-11-09). Loaded after every other sheet.

   The DAG canvas is the page: it opens at 100 % on the running node and gets
   all the height that is left. Above it there are at most two rows:

     1. Task header — ☰ · title · status · goal (one line) · Overview ·
        Rounds · Usage and cost · Flow/Team/Results · ⋯ · run control.
     2. Run strip (task-runtime.mjs .runtime-head) — Workers · progress ·
        elapsed · cost · DAG layers (one scrolling line) · Locate · View ·
        Pause/Stop · ⋯.

   Overview, Rounds and Usage are header entries whose content opens as a
   popover; notices about the canvas (freshness, control receipts) float on
   the canvas instead of taking rows. The "Work / Task" title row and the
   page-wide Remote Hand activity row are gone (the latter lives under the
   selected Device). The Assistant floats over the page (assistant-drag.mjs). */

/* ---- 1. Task header: one line ------------------------------------------- */
.task-page--spa .task-detail__head {
  position: relative;
  z-index: 20;
  flex-wrap: nowrap;
  min-height: 40px;
  gap: 8px;
  padding: 4px 10px;
}
.task-page--spa .task-detail__head > * { flex-shrink: 0; }
.task-page--spa .task-detail__head .task-detail__title { flex: 0 1 auto; min-width: 48px; max-width: 26%; }
/* The title shrinks inside its 26% box: an unshrinkable h2 (vlc-skin's
   `flex: none`) painted a long title over the status and the entries after it. */
.task-page--spa .task-detail__head .task-detail__title h2 {
  flex: 0 1 auto; min-width: 0;
  max-width: none; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: var(--mx-text-control); font-weight: 600;
}
.task-page--spa .task-detail__head > .task-detail__goal {
  flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 6px;
  min-height: 0; margin: 0; padding: 0 0 0 10px;
  border: 0; border-left: 1px solid var(--mx-line, #30363d); border-radius: 0; background: transparent;
}
/* No "Goal" label: the one line after the status can only be the goal. */
.task-page--spa .task-detail__head > .task-detail__goal b { display: none; }
.task-page--spa .task-detail__head > .task-detail__goal span {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--mx-dim, #8b949e); font-size: var(--mx-text-caption); line-height: 1.4;
}
.task-page--spa .task-detail__head .task-detail__actions { margin-left: 0; flex-wrap: nowrap; }

/* ---- Header entries: Overview · Rounds · Usage and cost ------------------- */
.task-page--spa .task-detail__head > .task-detail__info { flex: 0 1 auto; min-width: 0; }
.task-detail__info { display: flex; align-items: center; gap: 4px; }
.task-detail__info > div { position: relative; flex: 0 1 auto; min-width: 0; margin: 0; padding: 0; border: 0; background: none; }
.task-detail__info > .task-detail__overview { max-width: 300px; }
.task-detail__info .task-overview,
.task-detail__info .task-iter,
.task-detail__info .task-iter__entry { display: block; min-width: 0; max-width: 100%; }
.task-detail__info > div:empty { display: none; }
.task-detail__info .task-overview,
.task-detail__info .task-iter { margin: 0; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; gap: 0; }
/* One chip look for the three entries. */
.task-detail__info .task-overview > summary,
.task-detail__info .task-iter__entry > summary,
.task-detail__info .task-detail__usage > button {
  display: inline-flex; align-items: center; gap: 6px; box-sizing: border-box; height: 26px; max-width: 100%; margin: 0;
  padding: 0 10px; border: 1px solid var(--mx-line, #30363d); border-radius: 999px;
  background: transparent; color: var(--mx-dim, #8b949e); font: 500 var(--mx-text-caption)/1 var(--font, system-ui);
  white-space: nowrap; overflow: hidden; cursor: pointer; list-style: none; box-shadow: none;
}
.task-detail__info .task-overview > summary::-webkit-details-marker,
.task-detail__info .task-iter__entry > summary::-webkit-details-marker { display: none; }
.task-detail__info .task-overview > summary:hover,
.task-detail__info .task-iter__entry > summary:hover,
.task-detail__info .task-detail__usage > button:hover,
.task-detail__info details[open] > summary,
.task-detail__info .task-detail__usage > button[aria-expanded="true"] { border-color: var(--vl-primary, #58a6ff); color: var(--mx-ink, #e6edf3); }
.task-detail__info .task-overview > summary b { color: var(--mx-ink, #e6edf3); font-weight: 600; }
.task-detail__info .task-overview > summary .task-overview__summary-action { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.task-detail__info .task-overview > summary .task-overview__summary-action b { font-weight: 500; color: inherit; }
.task-detail__info summary .mx-tag { padding: 0 6px; font-size: var(--mx-text-caption); line-height: 16px; }
.task-detail__info .task-detail__bill [data-bill-total] { color: var(--mx-ink, #e6edf3); }
.task-detail__bill-warn { display: inline-grid; place-items: center; width: 14px; height: 14px; margin-left: 2px; border-radius: 50%; background: var(--vl-warning, #d29922); color: #0d1117; font: 700 var(--mx-text-caption)/1 var(--font, system-ui); }
/* Their content opens as a popover over the canvas. */
.task-detail__info .task-overview[open] > :not(summary),
.task-detail__info .task-iter__entry[open] > :not(summary),
.task-detail__info .task-detail__usage > [data-bill-detail] {
  position: absolute; z-index: 40; top: calc(100% + 6px); left: 0;
  box-sizing: border-box; width: 460px; max-width: calc(100vw - 32px); max-height: min(70vh, 640px); overflow: auto;
  margin: 0; padding: 12px; border: 1px solid var(--mx-line-strong, #3d444d); border-radius: 10px;
  background: var(--mx-panel, #161b22); box-shadow: 0 16px 40px rgba(1, 4, 9, .55);
  font-size: var(--mx-text-caption); line-height: 1.5; color: var(--mx-ink, #e6edf3);
}
/* The entries sit right of centre: the later ones open leftwards. */
.task-detail__info .task-iter__entry[open] > :not(summary),
.task-detail__info .task-detail__usage > [data-bill-detail] { left: auto; right: 0; }
.task-detail__info .task-iter__entry[open] > .task-iter__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.task-detail__info .task-iter__pop.mx-panel { display: flex; flex-direction: column; gap: 8px; width: 520px; }
.task-detail__info .task-iter__pop .task-iter__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.task-detail__info .task-detail__usage > [data-bill-detail] details.task-bill > summary { list-style: none; }

/* ---- 2. Run strip: one line — task-controls.css (".task-runtime--inline
   run strip"), so every host of the inline runtime gets it. -------------- */

/* ---- 3. The canvas takes the rest ---------------------------------------- */
.task-page--spa .task-detail__body { padding: 0; overflow: hidden; }
.task-page--spa .task-detail__runtime { position: relative; }
.task-page--spa .task-detail__dag { flex: 1 1 auto; min-height: 320px; }
/* Canvas notices float on the canvas, under the run strip. */
.task-page--spa .task-detail__notes {
  position: absolute; z-index: 7; top: 48px; left: 12px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  max-width: min(60%, 560px); pointer-events: none;
}
.task-page--spa .task-detail__notes > * {
  margin: 0; padding: 3px 9px; border: 1px solid var(--mx-line, #30363d); border-radius: 6px;
  background: rgba(13, 17, 23, .9); font-size: var(--mx-text-caption); line-height: 1.45; pointer-events: auto;
}
.task-page--spa .task-detail__notes > [hidden] { display: none; }
.task-page--spa .task-detail__notes > .task-detail__dag-note { border-color: #593037; }

/* ---- Page frame: no title row -------------------------------------------- */
/* The page is exactly the viewport under the top bar: the frame's own top
   padding moves into the Task page, so nothing scrolls off the bottom. */
.page:has(.task-page--spa) { padding-top: 0; padding-bottom: 0; }
.mx-next .mx-page.task-page--spa { box-sizing: border-box; padding-top: 8px; }
.task-page--spa .task-device-bar:empty { display: none; }

/* ---- Remote Hand activity: a compact entry under the selected Device ------ */
.task-tree__device-children .task-hand-activity { margin: 4px 0 6px; padding: 0; border-radius: 8px; }
.task-tree__device-children .task-hand-activity > summary { padding: 5px 9px; font-size: var(--mx-text-caption); color: var(--mx-dim, #8b949e); cursor: pointer; }
.task-tree__device-children .task-hand-activity__body { max-height: min(30vh, 260px); overflow-y: auto; font-size: var(--mx-text-caption); }

@media (max-width: 1100px) {
  .task-page--spa .task-detail__head > .task-detail__goal { display: none; }
  .task-page--spa .task-runtime--inline .runtime-head { flex-wrap: wrap; }
}

/* Narrow windows: the Overview chip gives up its text first, so Rounds and
   Usage and cost stay whole instead of being cut ("Rou", "用量与费") at 1024 px
   (multi-OS UI check, 2026-11-14: macOS fonts are wider than Linux). */
.task-detail__info > div:not(.task-detail__overview) { flex-shrink: 0; }
@media (max-width: 1100px) {
  .task-detail__info > .task-detail__overview { max-width: 180px; }
}

/* ---- Phone width: the Task header wraps, the canvas gets the screen ------- */
/* Hicode's phone check of a production Task (2026-11-14, 390 px): the header
   stayed on one line, the facts chips painted over the view tabs and
   「文件与预览」 sat past the right edge, so the files and the preview of the
   Task could not be reached. Here the header wraps: the facts and the view
   tabs each take a full row that scrolls sideways, and the canvas below them
   is tall enough to read a file or a preview. */
@media (max-width: 560px) {
  .task-page--spa .task-detail__head { flex-wrap: wrap; row-gap: 6px; }
  .task-page--spa .task-detail__head .task-detail__title { flex: 1 1 0; max-width: none; }
  .task-page--spa .task-detail__head > .task-detail__info,
  .task-page--spa .task-detail__head > .task-detail__views {
    order: 10; flex: 1 1 100%; min-width: 0; max-width: 100%;
    overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
  }
  .task-page--spa .task-detail__head > .task-detail__views { order: 11; }
  .task-page--spa .task-detail__head > .task-detail__info:empty { display: none; }
  .task-page--spa .task-detail__views .task-canvas-switch { flex: none; }
  .task-page--spa .task-detail { overflow: visible; }
  .task-page--spa .task-detail__dag { min-height: 72vh; }
  /* The canvas stays the screen's width: its run strip, layer path and plan
     line wrap or scroll inside it instead of widening the page, which then
     shifted sideways and cut off the left edge when a file was opened. */
  .task-page--spa .task-detail,
  .task-page--spa .task-detail__dag { min-width: 0; max-width: 100%; }
  .task-page--spa .task-detail__dag .runtime-head { flex-wrap: wrap; min-width: 0; }
  .task-page--spa .task-detail__dag .runtime-viewing { min-width: 0; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .task-page--spa .task-detail__dag .runtime-authority { flex-wrap: wrap; min-width: 0; }
  .task-page--spa .task-detail__dag .runtime-authority > * { min-width: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
  .task-page--spa .task-detail__dag .runtime-team { min-width: 0; max-width: 100%; flex-wrap: wrap; }
}

/* ==== Task page declutter (Hicode 2026-11-15) ==============================
   The canvas is the page. Above it there is the Task header only; everything
   about the run that is words (Workers, counts, elapsed, cost, what the graph
   is drawn from, the device binding) opens from the ⓘ of the canvas toolbar.
   The toolbar floats on the canvas, holds icons only, and shows a command only
   in the view where it acts and only while it can act. ---------------------- */

/* ---- 1. Task header: never cut, never overlapping -------------------------
   The header measures ITSELF (a container query), not the window: with the
   Task tree and a docked Assistant beside it, the column is far narrower than
   the viewport and the old `max-width` media rules never fired. Up to 1300 px
   it is two rows: ☰ · title · status · ⋯ · run control, then the view tabs
   (left) and the three facts chips (right). Wider, it is the one line.
   The second row starts at a fixed break, not where the first row runs out of
   room (Anna 2026-11-19): with the 停止 button of a running Task the tabs
   wrapped to the left of row two, and without it (a failed or finished Task)
   they stayed at the right of row one, so 团队 / 流程 / 文件与预览 / 结果
   jumped between two places as the Task's state changed. */
.task-page--spa .task-detail__head { flex-wrap: wrap; row-gap: 4px; container: taskhead / inline-size; }
.task-page--spa .task-detail__head .task-detail__title { min-width: 120px; max-width: 34%; }
.task-detail__info > div,
.task-page--spa .task-detail__head > .task-detail__info { flex-shrink: 0; }
@container taskhead (min-width: 561px) and (max-width: 1300px) {
  .task-page--spa .task-detail__head > .task-detail__goal { display: none; }
  .task-page--spa .task-detail__head .task-detail__title { flex: 1 1 60%; max-width: none; }
  .task-page--spa .task-detail__head > .task-detail__actions { order: 1; margin-left: auto; }
  .task-page--spa .task-detail__head::after { content: ''; order: 2; flex: 0 0 100%; height: 0; }
  .task-page--spa .task-detail__head > .task-detail__views { order: 3; }
  .task-page--spa .task-detail__head > .task-detail__info { order: 4; margin-left: auto; }
}

/* ---- 2. Canvas toolbar: icons, floating on the canvas ---------------------- */
.runtime-btn.runtime-btn--icon { display: inline-grid; place-items: center; width: 28px; padding: 0; }
.runtime-btn--icon .runtime-icon { display: block; }
.runtime-hand-buttons { display: inline-flex; align-items: center; gap: 2px; }
.runtime-hand-buttons[hidden] { display: none; }
.runtime-info-menu > .runtime-info-panel { width: min(520px, calc(100vw - 48px)); max-height: min(70vh, 640px); gap: 10px; padding: 12px; }
.runtime-info-panel .runtime-team { flex: none; flex-wrap: wrap; white-space: normal; overflow: visible; row-gap: 2px; }
.runtime-info-panel .runtime-info-note { margin: 0; }
.runtime-info-panel .runtime-info-note b { color: var(--mx-ink, #e6edf3); font-weight: 600; margin-right: 6px; }
.runtime-info-panel .runtime-adaptive,

.task-runtime--inline[data-header-views="1"] > .runtime-head {
  position: absolute; z-index: 8; top: 8px; left: 12px; right: 12px;
  min-height: 0; padding: 0; gap: 8px; border: 0; background: none;
  flex-wrap: nowrap; align-items: flex-start; pointer-events: none;
}
.task-runtime--inline[data-header-views="1"] > .runtime-head:has(.runtime-controls details[open]) { z-index: 96; }
.task-runtime--inline[data-header-views="1"] > .runtime-head > * { pointer-events: auto; }
.task-runtime--inline[data-header-views="1"] > .runtime-head > .runtime-viewing.task-layers,
.task-runtime--inline[data-header-views="1"] > .runtime-head > .runtime-controls {
  box-sizing: border-box; min-height: 32px; padding: 2px 3px;
  border: 1px solid var(--mx-line, #30363d); border-radius: 8px;
  background: rgba(13, 17, 23, .92); box-shadow: 0 4px 14px rgba(1, 4, 9, .35);
}
.task-runtime--inline[data-header-views="1"] > .runtime-head > .runtime-viewing.task-layers {
  flex: 0 1 auto; gap: 6px; padding: 2px 8px 2px 3px; overflow-x: auto; scrollbar-width: none;
}
.task-runtime--inline[data-header-views="1"] > .runtime-head > .runtime-viewing.task-layers[hidden] { display: none; }
.task-runtime--inline[data-header-views="1"] > .runtime-head > .runtime-controls { gap: 2px; margin-left: auto; }
.task-runtime--inline[data-header-views="1"] > .runtime-head .runtime-btn { border-color: transparent; background: transparent; }
.task-runtime--inline[data-header-views="1"] > .runtime-head .runtime-btn:hover:not(:disabled),
.task-runtime--inline[data-header-views="1"] > .runtime-head details[open] > summary.runtime-btn { background: color-mix(in srgb, var(--vl-primary, #1f6feb) 22%, transparent); }
.task-runtime--inline[data-header-views="1"] > .runtime-head .runtime-btn--primary { color: var(--vl-success, #3fb950); }
.task-runtime--inline[data-header-views="1"] > .runtime-head .runtime-btn--danger { color: var(--vl-danger, #f85149); }
.task-runtime--inline[data-header-views="1"] > .runtime-head .runtime-menu-panel .runtime-btn { border-color: var(--mx-line, #30363d); }
.task-layers__back { display: inline-grid; place-items: center; width: 26px; padding: 0; font-size: var(--mx-text-body); }
.task-layers__chip small { margin-left: 2px; }

/* A command shows only where it acts: Locate, View, the run's Pause / Continue /
   Stop / Run and Replan belong to the Flow graph. The Team view keeps ⓘ and ⋯. */
[data-canvas-shown]:not([data-canvas-shown="flow"]) .runtime-controls > [data-runtime-follow],
[data-canvas-shown]:not([data-canvas-shown="flow"]) .runtime-controls > .runtime-hand-buttons,
[data-canvas-shown]:not([data-canvas-shown="flow"]) .runtime-controls > [data-runtime-command],
[data-canvas-shown]:not([data-canvas-shown="flow"]) .runtime-controls > [data-runtime-plan],
[data-canvas-shown]:not([data-canvas-shown="flow"]) .runtime-head > .runtime-viewing.task-layers { display: none; }
/* Files and Results are not the graph: no toolbar, the whole canvas is theirs. */
.task-runtime--inline[data-header-views="1"][data-canvas-shown="files"] > .runtime-head,
.task-runtime--inline[data-header-views="1"][data-canvas-shown="results"] > .runtime-head { display: none; }
.task-runtime[data-header-views="1"][data-canvas-shown="files"] > .task-files-stage { inset: 0; }
.task-runtime[data-header-views="1"][data-canvas-shown="results"] > .task-canvas-layer { top: 12px; }

/* What the graph is drawn from (plan, live run, last observed) is said in the ⓘ
   panel; on the canvas the line stays for assistive technology only. */
.task-runtime--inline[data-header-views="1"] .runtime-authority--plan {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

/* ---- 3. Team view: a Worker's DAGs ------------------------------------------ */
.task-canvas-dags { display: grid; gap: 4px; }
.task-canvas-dag {
  all: unset; box-sizing: border-box; cursor: pointer; display: flex; align-items: center; gap: 8px;
  padding: 5px 8px 5px 18px; border: 1px solid #29364a; border-radius: 6px; font-size: var(--mx-text-caption); color: var(--mx-ink, #e6edf3);
}
.task-canvas-dag:hover, .task-canvas-dag:focus-visible { border-color: var(--vl-primary, #1f6feb); }
.task-canvas-dag > i { width: 7px; height: 7px; border-radius: 50%; background: var(--mx-dim, #8b949e); flex: none; }
.task-canvas-dag--active > i { background: var(--vl-primary, #58a6ff); box-shadow: 0 0 0 3px color-mix(in srgb, var(--vl-primary, #58a6ff) 25%, transparent); }
.task-canvas-dag--done > i { background: var(--vl-success, #3fb950); }
.task-canvas-dag--failed > i { background: var(--vl-danger, #f85149); }
.task-canvas-dag--blocked > i { background: var(--vl-warning, #d29922); }
.task-canvas-dag > span { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-canvas-dag > small { color: var(--mx-dim, #8b949e); font-variant-numeric: tabular-nums; }
.task-detail__placement:empty { display: none; }
.task-detail__placement .task-dispatch__nodes { margin: 6px 0 0; }

/* The shared graph's own path line repeats the layer line above (path, Collapse,
   Back to parent, Expand, Open run): on the Task page the layer line is the one
   place for them. Its round and revision history stay, under the toolbar. */
.task-runtime--inline[data-header-views="1"] .vl-runtime-dag__nav { position: absolute; z-index: 5; top: 48px; left: 12px; padding: 0; border: 0; background: none; }
.task-runtime--inline[data-header-views="1"] .vl-runtime-dag__nav > .vl-runtime-dag__crumbs,
.task-runtime--inline[data-header-views="1"] .vl-runtime-dag__nav > [data-dag-expand],
.task-runtime--inline[data-header-views="1"] .vl-runtime-dag__nav > [data-dag-open-run],
.task-runtime--inline[data-header-views="1"] .vl-runtime-dag__nav > [data-dag-collapse],
.task-runtime--inline[data-header-views="1"] .vl-runtime-dag__nav > [data-dag-close-run] { display: none; }

/* ---- 4. Files and Preview ---------------------------------------------------- */
/* Large window: the workbench itself, fixed over the page (the editor inside is
   not reloaded). The page frame is lifted above the top bar and the Assistant
   while it is open; the dim surround is the popup's own shadow. */
.task-files-work { position: relative; }
.task-files-work__pop {
  position: absolute; z-index: 3; top: 3px; right: 8px; display: inline-grid; place-items: center;
  width: 28px; height: 26px; padding: 0; border: 1px solid transparent; border-radius: 6px;
  background: rgba(13, 17, 23, .85); color: var(--mx-dim, #a3a9cb); cursor: pointer;
}
.task-files-work__pop:hover, .task-files-work__pop[aria-pressed="true"] { color: var(--mx-ink, #f3f5ff); border-color: var(--mx-line-strong, #3a467c); }
.task-files-work__tabs { padding-right: 44px; }
.task-files-work.is-popped {
  position: fixed; z-index: 200; inset: 28px 32px; border: 1px solid var(--mx-line-strong, #3d444d); border-radius: 10px; overflow: hidden;
  background: var(--mx-bg, #0b0d18); box-shadow: 0 0 0 100vmax rgba(1, 4, 9, .62), 0 24px 60px rgba(1, 4, 9, .6);
}
.page:has(.task-files-work.is-popped) { z-index: 130; }

/* Read-only code view: syntax colours (code-highlight.mjs). */
.task-files-code__text .tk-comment { color: #8b949e; font-style: italic; }
.task-files-code__text .tk-string { color: #a5d6ff; }
.task-files-code__text .tk-number { color: #79c0ff; }
.task-files-code__text .tk-keyword { color: #ff7b72; }
.task-files-code__text .tk-call { color: #d2a8ff; }
.task-files-code__text .tk-key, .task-files-code__text .tk-attr { color: #7ee787; }
.task-files-code__text .tk-tag { color: #7ee787; }
.task-files-code__text .tk-heading { color: #79c0ff; font-weight: 600; }
/* The popup is above the Task header too. */
.task-detail:has(.task-files-work.is-popped) > .task-detail__head { z-index: auto; }
/* How far the run is, on the canvas toolbar: numbers, no label. */
.runtime-controls > .runtime-progress-pill { flex: none; padding: 0 8px; font-size: var(--mx-text-caption); line-height: 26px; color: var(--mx-ink, #e6edf3); font-variant-numeric: tabular-nums; }
/* Members panel: a card is as wide as the panel, never wider. A long step or flow
   name is cut with an ellipsis inside its row (the full name is the row's
   title), instead of pushing the card under the panel's edge. */
.task-canvas-agent, .task-canvas-agent__steps, .task-canvas-dags { grid-template-columns: minmax(0, 1fr); }
.task-canvas-agent, .task-canvas-agent > *, .task-canvas-step, .task-canvas-flowbar { min-width: 0; box-sizing: border-box; }
.task-canvas-flowbar { max-width: 100%; }
.task-canvas-step > .task-canvas-step__name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-canvas-step > :not(.task-canvas-step__name) { flex: none; }
.task-canvas-agent__head { max-width: 100%; overflow-wrap: anywhere; }
/* A flow of dozens of steps: its progress bar stays inside the card. */
.task-canvas-flowbar__track { gap: 1px; overflow: hidden; }
.task-canvas-flowbar__track i { min-width: 0; }
/* The Hand Run's state beside its buttons: a word and a count. */
.runtime-hand-chip { padding: 0 8px; font-size: var(--mx-text-caption); line-height: 26px; white-space: nowrap; color: var(--mx-dim, #8b949e); font-variant-numeric: tabular-nums; }
.runtime-hand-chip[data-hand-run-state="delivered"] { color: var(--vl-primary, #58a6ff); }
.runtime-hand-chip[data-hand-run-state="completed"] { color: var(--vl-success, #3fb950); }
.runtime-hand-chip[data-hand-run-state="failed"] { color: var(--vl-danger, #f85149); }
.runtime-controls > .runtime-progress-pill[hidden] { display: none; }

/* Phone: the overview's next action is read whole, on as many lines as it needs
   (re-verify 2026-11-17, item 21: "已排队，尚无 …"). */
@media (max-width: 560px) {
  .task-detail__info .task-overview > summary { flex-wrap: wrap; }
  .task-detail__info .task-overview > summary .task-overview__summary-action { flex: 1 1 100%; overflow: visible; white-space: normal; text-overflow: clip; }
}

/* Several DAGs sent together: the toolbar menu that lists each DAG's plan and steps. */
.runtime-hand-bundle > summary { cursor: pointer; list-style: none; }
.runtime-hand-bundle > summary::-webkit-details-marker { display: none; }
.runtime-hand-bundle__panel { min-width: 360px; max-width: 520px; max-height: 70vh; overflow: auto; }
.runtime-hand-bundle__dags { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.runtime-hand-bundle__dag { padding: 8px 10px; border: 1px solid var(--mx-line, #30363d); border-radius: 8px; }
.runtime-hand-bundle__dag[data-used="0"] { opacity: .7; }
.runtime-hand-bundle__panel p { margin: 0; }
.runtime-hand-bundle__panel > p + p { margin-top: 4px; }
.runtime-hand-bundle__plan, .runtime-hand-bundle__planner { color: var(--mx-dim, #8b949e); font-size: var(--mx-text-caption); }
.runtime-hand-bundle__why { font-size: var(--mx-text-caption); margin-top: 2px; }
.runtime-hand-bundle__steps { margin: 6px 0 0; padding-left: 18px; font-size: var(--mx-text-caption); }
.runtime-hand-bundle__steps li[data-step-state="succeeded"] span { color: var(--vl-success, #3fb950); }
.runtime-hand-bundle__steps li[data-step-state="failed"] span { color: var(--vl-danger, #f85149); }

/* ---- Header beside a floating Assistant ----------------------------------
   assistant-drag.mjs clearTaskHeader(): an expanded floating window that overlaps
   the header's right part (its default place on a 1024px viewport) would cover the
   run controls; the header alone keeps clear of it. The page is not reserved. */
body.assistant-floating.assistant-clears-task-head .task-page--spa .task-detail__head {
  padding-right: var(--assistant-head-clear, 10px);
}
/* The canvas's floating run strip keeps clear the same way (its "more" menu holds Models). */
body.assistant-floating.assistant-clears-run-strip .task-runtime--inline[data-header-views="1"] > .runtime-head {
  right: var(--assistant-run-clear, 12px);
}

/* ==== Tight Task header (Irma 2026-11-22) ===================================
   One row from 900 px of header width (it was two rows below 1300 px):
     ☰ · icon · title over its goal · status · Flow › Process › Files | facts · ⋯ · run control
   The goal is the title's second line (it had its own boxed column and vanished
   first when space ran out); the three facts chips are smaller and the
   overview chip shows only its next action (its name is the tooltip). Below
   900 px the facts and tabs take a second row, as before. */
.task-page--spa .task-detail__head { min-height: 44px; gap: 8px; padding: 4px 10px; align-items: center; }
.task-page--spa .task-detail__head .task-detail__title {
  display: grid; flex: 1 1 auto; min-width: 140px; max-width: none; gap: 1px; align-content: center;
}
.task-page--spa .task-detail__head .task-detail__title h2 { line-height: 1.25; }
.task-page--spa .task-detail__head .task-detail__subtitle {
  margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--mx-dim, #8b949e); font-size: var(--mx-text-caption, 12px); line-height: 1.3;
}
.task-page--spa .task-detail__head > .mx-tag[data-task-status] { flex: none; }
.task-page--spa .task-detail__head > .task-detail__views { flex: none; }
.task-page--spa .task-detail__head > .task-detail__info { flex: none; gap: 4px; padding-left: 8px; border-left: 1px solid var(--mx-line, #30363d); }
.task-page--spa .task-detail__head > .task-detail__info:has(> div:not(:empty)) { display: flex; }
.task-detail__info .task-overview > summary,
.task-detail__info .task-iter__entry > summary,
.task-detail__info .task-detail__usage > button { height: 24px; padding: 0 8px; gap: 4px; }
.task-detail__info .task-overview > summary > b:first-child { display: none; }
.task-detail__info .task-overview > summary .task-overview__summary-action { max-width: 180px; }
.task-detail__info > .task-detail__overview { max-width: 220px; }
.task-page--spa .task-detail__head .task-detail__actions { gap: 6px; }
/* A container query cannot restyle the header itself, only its children: the
   title takes the room that is left (basis 0), so the row fits from 900 px. */
@container taskhead (min-width: 900px) {
  .task-page--spa .task-detail__head::after { display: none; }
  .task-page--spa .task-detail__head > .task-detail__actions,
  .task-page--spa .task-detail__head > .task-detail__views,
  .task-page--spa .task-detail__head > .task-detail__info { order: 0; margin-left: 0; }
  .task-page--spa .task-detail__head > .task-detail__title { flex: 1 1 0; min-width: 120px; max-width: none; }
}
@container taskhead (min-width: 561px) and (max-width: 899px) {
  .task-page--spa .task-detail__head > .task-detail__info { border-left: 0; padding-left: 0; }
}

/* design/readable.css */
/* Readable layer (UI cleanup PR 1, 2026-10-30; proposal:
   docs/ui-audit/2026-10/UI-CLEANUP-PROPOSAL.md).

   Loaded after the layout sheets and before polish.css. It adds the type scale
   (12 px floor, 14 px body on settings-style pages), raises the dim/faint text
   colours so help text is readable (ratios in the proposal, all >= 5.2:1 on
   every surface), and provides three shared patterns the page PRs use:
   status chips, the "Advanced" disclosure and the page-level save bar.
   Visual only: no selector here hides, moves or removes a control. */

.mx-next {
  /* The tiers themselves live in typography.css (:root). */
  --mx-fs-caption: var(--mx-text-caption);
  --mx-fs-label: var(--mx-text-control);
  --mx-fs-body: var(--mx-text-body);
  --mx-fs-section: var(--mx-text-section);
  --mx-fs-title: var(--mx-text-title);
  --mx-space-card: 20px;
  --mx-space-gap: 16px;
  --mx-row-h: 48px;
  /* #9198a1 / #848d97 were 5.9 / 5.1:1 on surface, but at 9.5 px they read as
     disabled. One step lighter keeps the hierarchy and passes at any size. */
  --mx-dim: #b7bfc8;
  --mx-faint: #9198a1;
}

/* Help and explanation text: 12 px, dim (was 9.5 px). */
.mx-next :is(.mx-help, .mx-hint, .mx-callout p) {
  font-size: var(--mx-fs-caption);
  line-height: var(--mx-lh-caption);
  color: var(--mx-dim);
}

/* Settings-style pages read at 14 px body. */
.mx-next .mx-page { font-size: var(--mx-fs-body); line-height: var(--mx-lh-body); }
.mx-next .mx-page h1 { font-size: var(--mx-fs-title); }

/* IDs in prose were painted near the background (1.4:1). */
.mx-next .mx-page code { color: var(--mx-dim); font-size: var(--mx-fs-caption); }

/* Status chips: tinted background, leading dot, AA text (7.0 / 7.0 / 5.8 / 6.9 / 8.2:1). */
.mx-next .mx-status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 999px;
  font-size: var(--mx-fs-caption); line-height: 20px; font-weight: 500; white-space: nowrap;
  color: var(--mx-dim); background: var(--mx-panel-2);
}
.mx-next .mx-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.mx-next .mx-status--ok { color: #56d364; background: rgba(63, 185, 80, .15); }
.mx-next .mx-status--warn { color: #e3b341; background: rgba(210, 153, 34, .16); }
.mx-next .mx-status--danger { color: #ff7b72; background: rgba(248, 81, 73, .15); }
.mx-next .mx-status--info { color: #79c0ff; background: rgba(88, 166, 255, .15); }

/* "Advanced" disclosure: closed by default, says what is inside. */
.mx-next details.mx-advanced { border-top: 1px dashed var(--mx-line-strong); margin-top: 16px; padding-top: 12px; }
.mx-next details.mx-advanced > summary {
  cursor: pointer; list-style: none;
  color: var(--mx-dim); font-size: var(--mx-fs-label); font-weight: 600;
}
.mx-next details.mx-advanced > summary::-webkit-details-marker { display: none; }
.mx-next details.mx-advanced > summary::before { content: "▸ "; }
.mx-next details.mx-advanced[open] > summary::before { content: "▾ "; }
.mx-next details.mx-advanced > summary .mx-advanced__what { font-weight: 400; color: var(--mx-faint); }
.mx-next details.mx-advanced > .mx-advanced__body { margin-top: 12px; display: grid; gap: 12px; }

/* Page-level save bar: the page's only primary button, shown when dirty. */
.mx-next .mx-savebar {
  position: sticky; bottom: 0; z-index: 5; margin-top: 16px;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border: 1px solid var(--mx-line-strong); border-radius: var(--mx-radius);
  background: rgba(22, 27, 34, .97); box-shadow: 0 -8px 24px -16px rgba(0, 0, 0, .7);
}
.mx-next .mx-savebar[hidden] { display: none !important; }
.mx-next .mx-savebar__text { flex: 1; color: var(--mx-ink); font-size: var(--mx-fs-body); }
.mx-next .mx-savebar__text::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--mx-warn); margin-right: 8px;
}
.mx-next .mx-savebar__status { color: var(--mx-dim); font-size: var(--mx-fs-caption); }

/* An offline Device keeps a readable name: its status chip already says
   "offline", so the row is dimmed by colour (5.9:1), not by opacity (2.3:1). */
.mx-next .set-device--offline > .set-row:first-child { color: var(--mx-faint); }
.mx-next .set-device--offline > .set-row:first-child .set-row__title { opacity: 1; color: var(--mx-dim); }

/* MoneyAmount (main-flows redesign F0, PRD §12.3.1): one dollar figure, and a
   source tag beside any Credits-sourced amount. Tags: gift 9.6:1, test 7.6:1. */
.mx-next .mx-money { display: inline-flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.mx-next .mx-money > b { font-weight: 600; font-variant-numeric: tabular-nums; }
.mx-next .mx-money--pending > b { font-weight: 500; color: var(--mx-dim); }
.mx-next .mx-src {
  display: inline-block; padding: 0 6px; border-radius: 4px;
  font-size: var(--mx-fs-caption); line-height: var(--mx-lh-caption); font-weight: 500;
}
.mx-next .mx-src--gift { color: #f2c65a; background: rgba(242, 198, 90, .14); }
.mx-next .mx-src--test { color: #79c0ff; background: rgba(88, 166, 255, .15); }
.mx-next .mx-src--credits { color: #f2c65a; background: rgba(242, 198, 90, .14); }

/* PickerChip: a default choice shown as its value in words; opens the existing selector. */
.mx-next .mx-pick {
  display: inline-flex; align-items: center; gap: 6px; max-width: 230px; height: 30px; padding: 0 10px;
  border: 1px solid rgba(240, 246, 252, .2); border-radius: 999px; background: transparent; color: inherit;
  font: inherit; font-size: var(--mx-fs-label); white-space: nowrap; cursor: pointer;
}
.mx-next .mx-pick__k { color: var(--mx-dim); }
.mx-next .mx-pick__v { overflow: hidden; text-overflow: ellipsis; }
.mx-next .mx-pick::after { content: "▾"; color: var(--mx-dim); font-size: var(--mx-fs-caption); }
.mx-next .mx-pick:focus-visible { outline: 2px solid #1f6feb; outline-offset: 2px; }
.mx-next .mx-pick[disabled] { cursor: default; }
.mx-next .mx-pick[disabled]::after { content: none; }

/* VerdictChip: how the input will be handled, with one switch (7.4:1; was about 1.5:1). */
.mx-next .mx-verdict {
  display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 12px; border-radius: 999px;
  font-size: var(--mx-fs-label); color: #b4bdff; background: rgba(125, 141, 255, .12); border: 1px solid rgba(125, 141, 255, .45);
}
.mx-next .mx-verdict--danger { color: #ff7b72; background: rgba(248, 81, 73, .12); border-color: rgba(248, 81, 73, .45); }
.mx-next .mx-verdict__switch {
  padding: 0; border: 0; background: none; color: #e6edf3; font: inherit; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}

/* Chinese has no letter case. An uppercase label on a Chinese page only turns
   the product words inside it into HAND / BRAIN / WORKSPACE / HAND KEY, which
   the rest of the page writes as Hand / Brain / Workspace (multi-OS UI check,
   2026-11-14). One rule for every uppercase label instead of one per sheet. */
:lang(zh) * { text-transform: none !important; }

/* design/typography.css */
/* 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); }

/* design/polish.css */
/* Visual polish pass, 2026-10 (baseline: docs/ui-audit/2026-10, PR #440).

   Loaded after every other product stylesheet, so a fix here wins without
   touching the layout files the UX threads are changing. Values only come
   from the shared design system (vl-design.css): one primary colour, one
   button shape, a visible keyboard focus on every control. Visual only: no
   selector here hides, moves or adds a control. */

/* 1. Keyboard focus on every control, not only buttons and links. */
.mx-next :is(input, select, textarea, summary, [role="tab"], [role="menuitem"]):focus-visible,
.mx-modal :is(button, a, input, select, textarea, summary):focus-visible,
#agent-chat-mount :is(button, a, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--vl-focus, #58a6ff);
  outline-offset: 2px;
}

/* 2. One primary colour. "Send and start" and the decision confirm were the
   only green fills in the product (audit 01 §13); they are the main action of
   their area, so they take the shared primary. */
#agent-chat-mount.mx-task-draft-open .send-btn[data-draft-send="true"],
.task-ai-echo__btn--primary {
  background: var(--vl-primary, #1f6feb);
  border-color: var(--vl-primary, #1f6feb);
  color: var(--vl-on-primary, #fff);
}
#agent-chat-mount.mx-task-draft-open .send-btn[data-draft-send="true"]:hover:not(:disabled),
.task-ai-echo__btn--primary:hover:not(:disabled) {
  background: var(--vl-primary-hover, #1a62d6);
  border-color: var(--vl-primary-hover, #1a62d6);
}

/* 3. Dialogs. components.css paints every `button[type=submit]` in a modal as a
   secondary button at a higher specificity than `.mx-btn--primary`, so the
   main action of every dialog ("Create Task Line", "Use this folder", ...)
   looked like Cancel (audit 01 §14-15). The submit keeps primary unless it is
   explicitly ghost or danger; modal buttons use the product button radius. */
html[data-theme] .mx-modal .mx-modal__foot button.mx-btn--primary[type="submit"],
.mx-modal .mx-modal__foot button.mx-btn--primary[type="submit"] {
  background: var(--vl-primary, #1f6feb) !important;
  border-color: var(--vl-primary, #1f6feb) !important;
  color: var(--vl-on-primary, #fff) !important;
}
html[data-theme] .mx-modal .mx-modal__foot button.mx-btn--primary[type="submit"]:hover:not(:disabled),
.mx-modal .mx-modal__foot button.mx-btn--primary[type="submit"]:hover:not(:disabled) {
  background: var(--vl-primary-hover, #1a62d6) !important;
  border-color: var(--vl-primary-hover, #1a62d6) !important;
}
html[data-theme] .mx-modal .mx-modal__foot button:disabled,
.mx-modal .mx-modal__foot button:disabled { opacity: .45; cursor: not-allowed; }
html[data-theme] .mx-modal .mx-btn,
html[data-theme] .mx-modal button[type="submit"],
html[data-theme] .mx-modal button[data-overlay-close]:not(.mx-close),
.mx-modal .mx-btn,
.mx-modal button[type="submit"],
.mx-modal button[data-overlay-close]:not(.mx-close) {
  min-height: var(--vl-control-md, 34px);
  border-radius: var(--vl-radius-md, 6px);
}

/* 4. "Remove this Workspace" rendered as unstyled 15px body text that read as a
   heading (audit 01 §13): the legacy light theme's element rule outranked its
   class. It is a low-emphasis destructive action: tertiary, danger on hover. */
html[data-theme] .mx-next .task-tree__remove-workspace {
  display: inline-flex;
  width: auto;
  min-height: var(--vl-control-sm, 28px);
  margin: 4px 0 0 4px;
  padding: 0 var(--vl-space-2, 8px);
  border: 1px solid transparent;
  border-radius: var(--vl-radius-md, 6px);
  background: transparent;
  color: var(--vl-text-faint, #848d97);
  font: var(--vl-weight-medium, 500) var(--vl-text-xs, 11px) / var(--vl-leading-xs, 16px) var(--vl-font-sans);
}
html[data-theme] .mx-next .task-tree__remove-workspace:hover {
  border-color: color-mix(in srgb, var(--vl-danger, #f85149) 45%, transparent);
  color: var(--vl-danger, #f85149);
}

/* 5. Icons: the notification bell is an SVG from the same stroke set as the
   rest of the chrome instead of a colour emoji. */
.mx-icon-btn svg { width: 15px; height: 15px; display: block; }

/* Problem record 1.3.172 #4: a denied Add Task / Remove Workspace entry stays legible and
   says why (#9198a1 on the #161b22 panel is >= 4.5:1; guarded by task-entry-permissions.test). */
html[data-theme] .mx-next .task-tree__remove-workspace.is-denied,
html[data-theme] .mx-next .task-tree__addline.is-denied { color: #9198a1; cursor: not-allowed; opacity: 1; }
html[data-theme] .mx-next .task-tree__remove-workspace.is-denied:hover { color: #9198a1; border-color: transparent; }
