/* StartLine controls, the single implementation for the workspace, the identity app and the event site:
   buttons, tabs, chips, checkboxes, radios and switches, kbd, meters, the selection bar, tooltips, the select caret and the page
   select menu, badges and the toast.
   Loads after tokens.css and shell.css; app stylesheets add layout (width, alignment, wrapping) but not
   their own size, shape or colour. Every runtime serves this file from platform/core/ui. */

/* Buttons: the default (also .secondary), .primary, .quiet, .danger and .text.
   44px tall by default (32–36px under [data-density="precise"] on fine pointers), 14px text.
   Forms of any of them: .small, .icon-button and .toggle. */
.button {
  box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--control-height); max-width: 100%; padding: 8px 16px;
  border: 1px solid var(--button-line); border-radius: var(--control-radius);
  background: var(--paper); color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 600; line-height: 1.4;
  text-align: center; text-decoration: none; overflow-wrap: anywhere; cursor: pointer;
}
@media (any-hover: hover) and (any-pointer: fine) {
  :where(:root:not([data-ui-hover="false"])) .button:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
}
.button.secondary { border-color: var(--button-line); background: var(--paper); color: var(--ink); }
@media (any-hover: hover) and (any-pointer: fine) {
  :where(:root:not([data-ui-hover="false"])) .button.secondary:hover { background: var(--hover); color: var(--ink); }
}
.button.primary { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
@media (any-hover: hover) and (any-pointer: fine) {
  :where(:root:not([data-ui-hover="false"])) .button.primary:hover { border-color: var(--accent-hover); background: var(--accent-hover); color: var(--on-accent); }
}
.button.quiet { border-color: transparent; background: transparent; color: var(--muted); }
@media (any-hover: hover) and (any-pointer: fine) {
  :where(:root:not([data-ui-hover="false"])) .button.quiet:hover { background: var(--hover); color: var(--ink); }
}
.button.danger { border-color: var(--danger-line); background: var(--paper); color: var(--danger); }
@media (any-hover: hover) and (any-pointer: fine) {
  :where(:root:not([data-ui-hover="false"])) .button.danger:hover { background: var(--danger-soft); color: var(--danger); }
}
.button.quiet.danger:not(:disabled, [aria-disabled="true"]) {
  border-color: transparent; background: transparent; color: var(--danger);
}
@media (any-hover: hover) and (any-pointer: fine) {
  :where(:root:not([data-ui-hover="false"])) .button.quiet.danger:not(:disabled, [aria-disabled="true"]):hover {
    border-color: transparent; background: var(--danger-soft); color: var(--danger);
  }
}
.button.text {
  min-width: 44px; border-color: transparent; background: transparent; color: var(--accent);
  padding-inline: 8px; font-weight: 600;
}
@media (any-hover: hover) and (any-pointer: fine) {
  :where(:root:not([data-ui-hover="false"])) .button.text:hover {
    background: var(--hover); color: var(--accent-hover); text-decoration: none;
  }
}
.button.text.danger { border-color: transparent; background: transparent; color: var(--danger); }
@media (any-hover: hover) and (any-pointer: fine) {
  :where(:root:not([data-ui-hover="false"])) .button.text.danger:hover {
    background: var(--danger-soft); color: var(--danger); text-decoration: none;
  }
}
.button:is(:disabled, [aria-disabled="true"]) {
  border-color: var(--line); background: var(--soft); color: var(--muted); cursor: not-allowed;
}
.button.quiet:is(:disabled, [aria-disabled="true"]),
.button.text:is(:disabled, [aria-disabled="true"]) {
  border-color: transparent; background: transparent; color: var(--muted);
}
.button.quiet:is(:disabled, [aria-disabled="true"]) { opacity: .45; }
@media (any-hover: hover) and (any-pointer: fine) {
  :where(:root:not([data-ui-hover="false"])) .button:is(:disabled, [aria-disabled="true"]):hover {
    border-color: var(--line); background: var(--soft); color: var(--muted); cursor: not-allowed;
  }
  :where(:root:not([data-ui-hover="false"])) .button.quiet:is(:disabled, [aria-disabled="true"]):hover,
  :where(:root:not([data-ui-hover="false"])) .button.text:is(:disabled, [aria-disabled="true"]):hover {
    border-color: transparent; background: transparent; color: var(--muted);
  }
}
/* AI 等待态保留品牌主色与极光扫光动效，不随通用 disabled 规则变灰。 */
.button[data-ai-busy="true"] {
  position: relative; overflow: hidden; isolation: isolate;
}
.button.primary[data-ai-busy="true"],
.button.primary[data-ai-busy="true"]:is(:disabled, [aria-disabled="true"]) {
  border-color: var(--accent); background: var(--accent); color: var(--on-accent); cursor: progress;
}
/* 默认次按钮（裸 .button 或 .button.secondary）与 .quiet 共用浅强调底，避免 React Button 默认态变灰。 */
.button:not(.primary, .quiet, .text, .danger)[data-ai-busy="true"],
.button:not(.primary, .quiet, .text, .danger)[data-ai-busy="true"]:is(:disabled, [aria-disabled="true"]),
.button.secondary[data-ai-busy="true"],
.button.secondary[data-ai-busy="true"]:is(:disabled, [aria-disabled="true"]),
.button.quiet[data-ai-busy="true"],
.button.quiet[data-ai-busy="true"]:is(:disabled, [aria-disabled="true"]) {
  border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent);
  opacity: 1; cursor: progress;
}
.button.text[data-ai-busy="true"],
.button.text[data-ai-busy="true"]:is(:disabled, [aria-disabled="true"]) {
  border-color: transparent; background: var(--accent-soft); color: var(--accent); cursor: progress;
}
@media (any-hover: hover) and (any-pointer: fine) {
  :where(:root:not([data-ui-hover="false"])) .button.primary[data-ai-busy="true"]:is(:disabled, [aria-disabled="true"]):hover {
    border-color: var(--accent); background: var(--accent); color: var(--on-accent); cursor: progress;
  }
  :where(:root:not([data-ui-hover="false"])) .button:not(.primary, .quiet, .text, .danger)[data-ai-busy="true"]:is(:disabled, [aria-disabled="true"]):hover,
  :where(:root:not([data-ui-hover="false"])) .button.secondary[data-ai-busy="true"]:is(:disabled, [aria-disabled="true"]):hover,
  :where(:root:not([data-ui-hover="false"])) .button.quiet[data-ai-busy="true"]:is(:disabled, [aria-disabled="true"]):hover {
    border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); cursor: progress;
  }
  :where(:root:not([data-ui-hover="false"])) .button.text[data-ai-busy="true"]:is(:disabled, [aria-disabled="true"]):hover {
    border-color: transparent; background: var(--accent-soft); color: var(--accent); cursor: progress;
  }
}
.button[data-ai-busy="true"]::after {
  content: ""; position: absolute; inset: 0; width: 65%; border-radius: inherit;
  pointer-events: none; will-change: transform;
  background: linear-gradient(105deg, transparent 0%, rgb(255 255 255 / .24) 50%, transparent 100%);
  transform: translate3d(-140%, 0, 0) skewX(-18deg);
  animation: ai-btn-shimmer 1.75s cubic-bezier(.4, 0, .2, 1) infinite;
}
.button:is(.secondary, .quiet, .text)[data-ai-busy="true"]::after,
.button:not(.primary, .quiet, .text, .danger)[data-ai-busy="true"]::after {
  background: linear-gradient(105deg, transparent 0%, color-mix(in srgb, var(--accent) 18%, transparent) 50%, transparent 100%);
}
.ai-busy-spinner { flex: none; display: inline-block; width: 16px; height: 16px; vertical-align: middle; }
.ai-busy-ring { transform-origin: 50% 50%; animation: ai-ring-spin 1.15s linear infinite; }
.ai-busy-star { transform-origin: 50% 50%; animation: ai-star-pulse 1.5s ease-in-out infinite; }
@keyframes ai-btn-shimmer {
  0% { transform: translate3d(-140%, 0, 0) skewX(-18deg); }
  100% { transform: translate3d(260%, 0, 0) skewX(-18deg); }
}
@keyframes ai-ring-spin {
  to { transform: rotate(360deg); }
}
@keyframes ai-star-pulse {
  0%, 100% { transform: scale(.85); opacity: .72; }
  50% { transform: scale(1.06); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .button[data-ai-busy="true"]::after { display: none; animation: none; }
  .ai-busy-ring, .ai-busy-star { animation: none; }
}
@media (forced-colors: active) {
  .button[data-ai-busy="true"]::after { display: none; }
  .button[data-ai-busy="true"],
  .button[data-ai-busy="true"]:is(:disabled, [aria-disabled="true"]) {
    border-color: Highlight; color: CanvasText;
  }
}
.button.small { padding: 8px 12px; font-size: 13px; }
/* Two forms of the same buttons, not further kinds. .icon-button: one line icon, no text, a 44px square;
   it needs an accessible name. .toggle: a filter or switch that stays pressed (aria-pressed="true")
   takes the tinted current-item colours instead of becoming a primary button. */
/* One class of specificity, so a module can still place or resize one it owns. */
:where(.button).icon-button { flex: none; width: var(--control-height); min-width: var(--control-height); height: var(--control-height); padding: 0; }
.button.toggle[aria-pressed="true"] { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }
@media (any-hover: hover) and (any-pointer: fine) {
  :where(:root:not([data-ui-hover="false"])) .button.toggle[aria-pressed="true"]:hover { background: var(--accent-soft); color: var(--accent); }
}
.button:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset); }
/* A row of actions: 8px apart, wrapping on narrow screens. */
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--control-gap); }

/* Tabs: a second row under a page title, inside dialogs and inside panels. The current tab is tinted;
   a row that must fit uses .fill (always) or .fill-phone (under 600px) to share the width instead of scrolling. */
.shell-tabs {
  display: flex; gap: 4px; width: fit-content; max-width: 100%; margin: 0 0 16px; padding: 4px;
  overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--paper); scrollbar-width: none;
}
.shell-tabs::-webkit-scrollbar { display: none; }
.shell-tabs.fill { width: 100%; overflow-x: visible; }
.shell-tab {
  display: inline-flex; flex: none; align-items: center; justify-content: center; gap: 6px;
  min-width: 44px; min-height: 44px; padding: 8px 16px; border: 0; border-radius: var(--control-radius);
  background: transparent; color: var(--muted);
  font: inherit; font-size: 14px; font-weight: 600; line-height: 1.4; white-space: nowrap; text-decoration: none; cursor: pointer;
}
.shell-tabs.fill > .shell-tab { flex: 1 1 0; min-width: 0; padding-inline: 8px; white-space: normal; text-align: center; }
@media (any-hover: hover) and (any-pointer: fine) {
  :where(:root:not([data-ui-hover="false"])) .shell-tab:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
}
.shell-tab:is([aria-current="page"], [aria-current="true"], [aria-selected="true"], [aria-pressed="true"]) { background: var(--accent-soft); color: var(--accent); }
@media (any-hover: hover) and (any-pointer: fine) {
  :where(:root:not([data-ui-hover="false"])) .shell-tab:is([aria-current="page"], [aria-current="true"], [aria-selected="true"], [aria-pressed="true"]):hover { background: var(--accent-soft); color: var(--accent); }
}
.shell-tab:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: calc(-1 * var(--focus-width)); }
.shell-tab small { color: inherit; font-size: 12px; font-weight: 400; opacity: .8; }
@media (max-width: 599px) {
  .shell-tab { padding-inline: 12px; }
  .shell-tabs.fill-phone { width: 100%; overflow-x: visible; }
  .shell-tabs.fill-phone > .shell-tab { flex: 1 1 0; min-width: 0; padding-inline: 8px; white-space: normal; text-align: center; }
  /* Five tabs on a 320–390px screen: smaller text before a label wraps. */
  .shell-tabs:is(.fill, .fill-phone) > .shell-tab { padding-inline: 4px; font-size: 13px; }
}

/* Line tabs (.shell-tabs.is-line): page-level underline switcher without outer box. */
.shell-tabs.is-line {
  gap: 20px; width: 100%; padding: 0; border: 0; border-bottom: 1px solid var(--line);
  border-radius: 0; background: transparent;
}
.shell-tabs.is-line > .shell-tab {
  position: relative; flex: none; justify-content: center; min-width: 44px; min-height: 44px; padding: 8px 0;
  border-radius: 0; background: transparent; color: var(--muted); font-weight: 500;
}
@media (any-hover: hover) and (any-pointer: fine) {
  :where(:root:not([data-ui-hover="false"])) .shell-tabs.is-line > .shell-tab:hover {
    background: transparent; color: var(--ink);
  }
}
.shell-tabs.is-line > .shell-tab:is(
  [aria-current="page"], [aria-current="true"], [aria-selected="true"], [aria-pressed="true"]
) {
  background: transparent; color: var(--ink); font-weight: 600;
}
.shell-tabs.is-line > .shell-tab:is(
  [aria-current="page"], [aria-current="true"], [aria-selected="true"], [aria-pressed="true"]
)::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  border-radius: 2px; background: var(--ink);
}
.shell-tabs.is-line > .shell-tab small {
  min-width: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font: 600 11.5px/18px var(--font-num); opacity: 1; text-align: center;
}
@media (max-width: 599px) {
  .shell-tabs.is-line { gap: 16px; }
  .shell-tabs.is-line > .shell-tab { padding-inline: 0; }
}

/* Segmented track (.segmented): quiet recessed track with lifted active choice. */
.segmented {
  position: relative; display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px; max-width: 100%;
  padding: 2px; border-radius: var(--control-radius); background: var(--track);
}
.segmented > :is(button, a) {
  position: relative; z-index: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 44px; min-height: 44px; padding: 0 11px; border: 0; border-radius: var(--radius-item);
  background: transparent; color: var(--muted); font: inherit; font-size: var(--text-meta);
  font-weight: 500; text-decoration: none; cursor: pointer;
}
@media (any-hover: hover) and (any-pointer: fine) {
  :where(:root:not([data-ui-hover="false"])) .segmented > :is(button, a):hover {
    color: var(--ink); text-decoration: none;
  }
}
.segmented > :is(button, a):is(
  [aria-pressed="true"], [aria-current="page"], [aria-current="true"], [aria-selected="true"]
) {
  background: var(--paper); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-nav);
}
.segmented > :is(button, a) :is(small, .segmented-count) {
  color: var(--muted); font: 600 12px/1 var(--font-num); font-variant-numeric: tabular-nums;
}
.segmented > :is(button, a):is(
  [aria-pressed="true"], [aria-current="page"], [aria-current="true"], [aria-selected="true"]
) :is(small, .segmented-count) {
  color: var(--accent);
}
.segmented > :is(button, a):focus-visible {
  outline: var(--focus-width) solid var(--focus); outline-offset: calc(-1 * var(--focus-width));
}
/* The thumb slides to the new choice (installSharedControls in overlays.mjs; skipped under reduced motion).
   Position moves via GPU-composited translate3d; width/height stay explicit so corners and borders never stretch. */
.segmented-glide {
  position: absolute; left: 0; top: 0; z-index: 0; border-radius: var(--radius-item);
  background: var(--paper); box-shadow: var(--shadow-nav); pointer-events: none;
  transition: transform var(--motion-base) var(--ease-standard),
    width var(--motion-base) var(--ease-standard), height var(--motion-base) var(--ease-standard);
}
.segmented.is-gliding > :is(button, a):is([aria-pressed="true"], [aria-current="page"], [aria-current="true"], [aria-selected="true"]) {
  background: transparent; box-shadow: none;
}
@media (forced-colors: active) {
  .segmented { border: 1px solid CanvasText; }
  .segmented > :is(button, a):is(
    [aria-pressed="true"], [aria-current="page"], [aria-current="true"], [aria-selected="true"]
  ) {
    outline: 2px solid Highlight; outline-offset: -2px;
  }
}

/* Page-level KPI counter strip (.ui-kpis): label above, large tabular figure below. */
.ui-kpis { display: flex; flex-wrap: wrap; gap: 12px 0; margin: 0; }
.ui-kpis > div {
  display: grid; align-content: start; gap: 2px; padding: 0 28px; border-left: 1px solid var(--line);
}
.ui-kpis > div:first-child { padding-left: 0; border-left: 0; }
.ui-kpis dt { margin: 0; color: var(--muted); font-size: var(--text-meta); font-weight: 500; }
.ui-kpis dd {
  margin: 0; color: var(--ink); font: 600 var(--text-display)/1.1 var(--font-num);
  letter-spacing: -.02em; font-variant-numeric: tabular-nums;
}
.ui-kpis dd small {
  margin-left: 4px; color: var(--muted); font: 500 var(--text-meta)/1 var(--font-ui); letter-spacing: 0;
}
.ui-kpis > .is-accent dd { color: var(--accent); }
.ui-kpis > .is-warn dd { color: var(--warn); }
.ui-kpis > .is-danger dd { color: var(--danger); }
@media (max-width: 599px) {
  .ui-kpis > div { padding: 0 14px; }
  .ui-kpis > div:first-child { padding-left: 0; }
  .ui-kpis dd { font-size: 24px; }
  .ui-kpis dt { font-size: var(--text-caption); }
}

/* Opt a form or page into the shared appearance. File pickers and choice controls keep their own native semantics. */
.ui-fields :where(input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"]), select, textarea) {
  --control-border-inset: 0px;
  box-sizing: border-box; min-height: var(--control-height); min-width: 0; max-width: 100%;
  padding: calc(var(--control-pad-block) - var(--control-border-inset)) calc(var(--control-pad-inline) - var(--control-border-inset));
  border: 1px solid var(--control-line); border-radius: var(--control-radius); corner-shape: var(--corner-shape);
  color: var(--ink); background-color: var(--raised); font: inherit; font-size: var(--text-input); line-height: 1.4;
}
.ui-fields :where(input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"]), select, textarea):focus {
  --control-border-inset: 1px; border: 2px solid var(--focus); outline: none; box-shadow: none;
}
/* Standard single-line fields share the button footprint even when the page inherits a taller line box.
   Keep specificity low so specialist controls can supply their own explicit dimensions. */
:where(
  select:not([multiple], [size]),
  input:is(:not([type]), [type="text"], [type="search"], [type="password"], [type="email"], [type="tel"], [type="url"], [type="number"]),
  input:is([type="date"], [type="time"], [type="datetime-local"], [type="month"], [type="week"])
) {
  --control-pad-block: var(--space-8);
  box-sizing: border-box;
  height: var(--control-height);
  min-height: var(--control-height);
}
/* Native date/time inputs must shrink cleanly with their field on narrow mobile grids and iOS Safari. */
input:is([type="date"], [type="time"], [type="datetime-local"]) {
  -webkit-appearance: none; appearance: none; display: inline-flex; align-items: center;
  box-sizing: border-box; min-inline-size: 0; inline-size: 100%; max-inline-size: 100%;
  height: var(--control-height); min-height: var(--control-height); line-height: normal;
}
input:is([type="date"], [type="time"], [type="datetime-local"])::-webkit-date-and-time-value {
  min-inline-size: 0; margin: 0; text-align: start;
}
.ui-fields :where(input, select, textarea):is(:disabled, [readonly]) { color: var(--muted); background-color: var(--soft); }
.ui-fields textarea { resize: vertical; }
@media (forced-colors: active) {
  .ui-fields :where(input, select, textarea):focus-visible { outline: 2px solid Highlight; outline-offset: -2px; }
}

/* Dropdowns draw the same caret in every app and theme. Local field rules often reset background and
   padding with shorthands, so the caret's own properties are kept here with !important. */
select:not([multiple], [size]) {
  appearance: none !important; -webkit-appearance: none !important; overflow: hidden; cursor: pointer;
  padding-right: calc(var(--control-select-pad-right) - var(--control-border-inset, 0px)) !important;
  --select-caret-x: calc(var(--control-select-inset) - var(--control-border-inset, 0px));
  --select-caret-y: calc(50% + var(--control-select-caret-offset));
  background-image: var(--control-select-icon) !important;
  background-position: calc(100% - var(--select-caret-x) - var(--control-select-caret-width)) var(--select-caret-y),
    calc(100% - var(--select-caret-x)) var(--select-caret-y) !important;
  background-repeat: no-repeat !important; background-size: var(--control-select-caret-width) var(--control-select-caret-width) !important;
}
@media (forced-colors: active) {
  select:not([multiple], [size]) {
    appearance: auto !important; -webkit-appearance: auto !important;
    padding-right: var(--control-pad-inline) !important; background-image: none !important;
  }
}

/* The page select menu (presentation.mjs enhanceSelectMenus). A transparent trigger covers the native field,
   because iOS raises its own picker on a direct touch even after pointerdown is cancelled; the native select
   keeps its value, change event, focus and keyboard handling. The menu is as wide as its field, opens below
   (or above) without covering it, scrolls inside and stays in the viewport (guidelines §4). */
.select-shell { position: relative; display: block; min-width: 0; max-width: 100%; }
.select-shell:has(> select[hidden]) { display: none; }
.select-shell > select { pointer-events: none; }
.select-trigger { position: absolute; inset: 0; z-index: 1; display: block; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; background: transparent; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.select-trigger:focus, .select-trigger:focus-visible { outline: none; box-shadow: none; }
select:disabled + .select-trigger { pointer-events: none; cursor: default; }
/* Keep the caret and text fixed when a field compensates for its thicker focus border. */
/* While its menu is open, a bordered field shows the one focus line on its own border (guidelines §4). */
select[data-select-menu-open="true"] { border-color: var(--focus); }
.select-menu {
  box-sizing: border-box; position: fixed; z-index: var(--layer-dropdown); display: grid; gap: 2px; margin: 0; padding: 4px;
  overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--line);
  border-radius: calc(var(--radius-item) + 4px);
  corner-shape: var(--corner-shape); background: var(--raised); color: var(--ink); box-shadow: var(--shadow-overlay);
}
.select-menu:focus { outline: none; }
.select-menu:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: calc(-1 * var(--focus-width)); }
.select-menu-option {
  display: flex; align-items: center; gap: var(--space-8); min-height: 44px; padding: 8px; border-radius: var(--radius-item);
  color: var(--ink); font-size: var(--text-body); line-height: 1.5; overflow-wrap: anywhere; cursor: pointer;
}
.select-menu-option[data-active="true"] { background: var(--accent-soft); }
@media (any-hover: hover) and (any-pointer: fine) {
  :where(:root:not([data-ui-hover="false"])) .select-menu-option:hover { background: var(--accent-soft); }
}
.select-menu-option[aria-selected="true"] { color: var(--accent); font-weight: 600; }
.select-menu-option[aria-disabled="true"] { color: var(--muted); opacity: .55; cursor: default; }
.select-menu-check { flex: 0 0 16px; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; visibility: hidden; }
.select-menu-option[aria-selected="true"] .select-menu-check { visibility: visible; }
.select-menu-label { min-width: 0; overflow-wrap: anywhere; }
/* Long lists (more than 12 options, or data-select-search="on") open with a filter box above the list. */
.select-menu.is-searchable { overflow: hidden; grid-template-rows: auto minmax(0, 1fr) auto; }
.select-menu-list { display: grid; gap: 2px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.select-menu-search {
  --control-border-inset: 0px;
  box-sizing: border-box; width: 100%; height: var(--control-height); min-height: var(--control-height);
  margin: 0 0 2px;
  padding: calc(6px - var(--control-border-inset)) calc(10px - var(--control-border-inset));
  appearance: none;
  border: 1px solid var(--control-line); border-radius: var(--radius-item); background: var(--paper); color: var(--ink);
  font: inherit; font-size: var(--text-input);
}
/* Focus thickens the one border inward (§4): --control-border-inset gives back the extra pixel so nothing moves. */
.select-menu-search:focus {
  --control-border-inset: 1px; border: 2px solid var(--focus); outline: none; box-shadow: none;
}
.select-menu-empty { margin: 0; padding: 8px 10px; color: var(--muted); font-size: var(--text-meta); }
@media (forced-colors: active) {
  .select-menu { border: 2px solid CanvasText; }
  .select-menu-option[data-active="true"] { outline: 2px solid Highlight; outline-offset: -2px; }
}

/* Badges: one main business state per object (guidelines §7). Neutral is a draft or not-yet state;
   the tones are good (confirmed, published, official), warn (to check, provisional, pending sync),
   accent (adopted, in progress), danger (failed, blocked). The text always names the state. */
.badge {
  display: inline-flex; align-items: center; width: fit-content; max-width: 100%; padding: 2px 8px;
  border-radius: var(--radius-tag); background: var(--soft); color: var(--muted);
  font-size: var(--text-caption); font-weight: 500; line-height: 1.6; overflow-wrap: anywhere;
}
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
@media (forced-colors: active) { .badge { border: 1px solid CanvasText; } }

/* Dot-and-text status for rows and cells (.status). Completed states stay neutral ink with a green dot. */
.status {
  display: inline-flex; align-items: center; gap: var(--space-8); max-width: 100%;
  color: var(--ink-2); font-size: var(--text-meta); line-height: 1.5; overflow-wrap: anywhere;
}
.status::before {
  content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--dot-neutral);
}
.status.neutral { color: var(--muted); }
.status.good::before { background: var(--good); }
.status.warn { color: var(--warn); font-weight: 600; }
.status.warn::before { background: var(--warn); }
.status.accent { color: var(--accent); font-weight: 600; }
.status.accent::before { background: var(--accent); }
.status.danger { color: var(--danger); font-weight: 600; }
.status.danger::before { background: var(--danger); }
@media (forced-colors: active) { .status::before { border: 1px solid CanvasText; } }

/* Toast: what just changed, at most one action, never takes focus (guidelines §5). Fixed above the
   page at the bottom centre; a module may stack it in its own region instead. .is-error (or
   data-tone="error") is a failure that does not block the page; blocking failures stay on the page. */
.toast {
  position: fixed; z-index: var(--layer-toast); inset: auto auto calc(32px + env(safe-area-inset-bottom)) 50%;
  width: max-content; max-width: min(560px, calc(100vw - 32px)); margin: 0; padding: 12px 16px;
  border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--raised); color: var(--ink);
  background: light-dark(var(--ink), var(--raised)); color: light-dark(var(--paper), var(--ink)); border-color: light-dark(transparent, var(--line));
  box-shadow: var(--shadow-overlay); transform: translateX(-50%);
  font-size: var(--text-body); font-weight: 500; line-height: 1.6; text-align: left; overflow-wrap: anywhere;
}
.toast[hidden] { display: none; }
.toast:is(.is-error, [data-tone="error"]) { background: var(--danger); color: var(--on-danger); }
.toast[data-action] { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.toast-action {
  flex: none; min-height: 44px; margin-block: -12px; padding: 0 4px; border: 0; background: transparent; color: inherit;
  font: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.toast-action:focus-visible { outline: var(--focus-width) solid currentColor; outline-offset: -4px; }
@media (max-width: 599px) {
  .toast { bottom: calc(72px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: no-preference) {
  .toast:not([hidden]) { animation: toast-in var(--motion-base) var(--ease-standard); }
}
@keyframes toast-in { from { opacity: 0; translate: 0 8px; } }
@media (forced-colors: active) { .toast { border: 1px solid CanvasText; } }

/* 常驻提示条（规范 §5）：中性浅底 + 1px 发丝细框 + 6px 语义圆点，告别四边彩框与左侧粗竖条；
   空态（.empty / .empty-inline）、就近错误（.inline-error）与加载占位（.skeleton）同源维护。 */
.notice {
  --notice-dot: var(--dot-neutral);
  position: relative; padding: 12px 16px 12px 28px;
  border: 1px solid var(--line-soft); border-radius: var(--radius-control); corner-shape: var(--corner-shape);
  background: var(--soft); color: var(--ink-2); font-size: var(--text-meta); line-height: 1.6; overflow-wrap: anywhere;
}
.notice::before {
  content: ""; position: absolute; inset-inline-start: 14px; top: 19px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--notice-dot);
}
.notice[hidden] { display: none; }
.notice strong { color: var(--ink); }
.notice :is(p, ul) { margin: 0; }
.notice > * + * { margin-top: 4px; }
.notice.good { --notice-dot: var(--good); }
.notice.warn { --notice-dot: var(--warn); }
.notice.error { --notice-dot: var(--danger); }
.notice.error strong { color: var(--danger); }
.notice .actions, .notice .button-row, .notice .panel-actions {
  display: flex; flex-wrap: wrap; gap: var(--control-gap); justify-content: flex-start; margin-top: 10px;
}
@media (max-width: 599px) {
  .notice { padding: 12px 12px 12px 26px; }
  .notice::before { inset-inline-start: 12px; }
}
.inline-error { margin: 0; color: var(--danger); font-size: var(--text-meta); line-height: 1.6; overflow-wrap: anywhere; }
.empty { padding: 40px 24px; border: 0; border-radius: var(--radius-panel); corner-shape: var(--corner-shape); background: transparent; text-align: center; }
.empty > :is(h2, h3) { margin: 0 0 8px; }
.empty > p { max-width: 480px; margin: 0 auto 24px; color: var(--muted); }
.empty > p:last-child { margin-bottom: 0; }
.empty-inline { display: grid; justify-items: start; gap: var(--space-8); margin: 0; padding: 16px; border: 0; border-radius: var(--radius-control); color: var(--muted); overflow-wrap: anywhere; }
.empty-inline :is(p, h3) { margin: 0; }
.skeleton { display: grid; gap: 12px; padding: 4px 0; }
.skeleton-label { margin: 0 0 4px; color: var(--muted); font-size: var(--text-meta); }
.skeleton-line { display: block; height: 14px; border-radius: var(--radius-tag); background: var(--soft); }
.skeleton-line:nth-of-type(3n + 2) { width: 72%; }
.skeleton-line:nth-of-type(3n) { width: 48%; }
@media (prefers-reduced-motion: no-preference) {
  .skeleton-line { animation: skeleton-pulse 1.2s ease-in-out infinite alternate; }
}
@keyframes skeleton-pulse { to { opacity: .45; } }
@media (forced-colors: active) {
  .notice, .empty, .empty-inline { border: 1px solid CanvasText; }
  .notice::before { background: CanvasText; forced-color-adjust: none; }
  .skeleton-line { background: GrayText; }
}

/* Popovers and menus (guidelines §2 列表与工具栏): a panel that floats over the page without pushing rows
   aside. overlays.mjs placeMenu() anchors it to its button, flips it above and clamps it in the viewport,
   and turns it into a bottom sheet on a phone; menuRoom() does the same inside a scrolling list.
   .popover is the surface (filters, small forms); .menu adds the list of .menu-item actions. */
.popover {
  z-index: var(--layer-popover); box-sizing: border-box; max-width: calc(100vw - 16px); padding: 12px;
  overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: var(--radius-panel);
  corner-shape: var(--corner-shape); background: var(--raised); color: var(--ink); box-shadow: var(--shadow-overlay);
}
.popover[hidden] { display: none; }
.popover[data-menu-placement="sheet"] { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.menu {
  display: grid; align-content: start; gap: 2px; min-width: 180px; padding: 4px;
  border-radius: calc(var(--radius-item) + 4px);
}
.menu[data-menu-placement="sheet"] { padding-bottom: max(4px, env(safe-area-inset-bottom)); }
.menu-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-8); padding: 4px 4px 8px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-head strong { min-width: 0; overflow-wrap: anywhere; }
.menu-item {
  display: flex; align-items: center; gap: var(--space-8); width: 100%; min-height: 44px; margin: 0; padding: 8px 12px;
  border: 0; border-radius: var(--radius-item); background: transparent; color: var(--ink);
  font: inherit; font-size: var(--text-body); line-height: 1.4; text-align: left; text-decoration: none; overflow-wrap: anywhere; cursor: pointer;
}
.menu-item svg { flex: none; width: 18px; height: 18px; color: var(--muted); }
.menu-item.danger, .menu-item.danger svg { color: var(--danger); }
@media (any-hover: hover) and (any-pointer: fine) {
  :where(:root:not([data-ui-hover="false"])) .menu-item:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
  :where(:root:not([data-ui-hover="false"])) .menu-item.danger:hover { background: var(--danger-soft); color: var(--danger); }
}
.menu-item:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: calc(-1 * var(--focus-width)); }
.menu-item:is(:disabled, [aria-disabled="true"]) { color: var(--muted); cursor: not-allowed; }
@media (forced-colors: active) { .popover { border: 2px solid CanvasText; } }

/* Modal dialog (guidelines §2 呈现方式选择): only for a decision with consequences or a focused task, never nested.
   A native <dialog> opened with showModal(), so it sits in the top layer. The plain form has a title, a body
   and actions (overlays.mjs confirmDialog builds one); .dialog-sections has a ruled head and a padded body
   for larger tasks. Modules set width and height; they do not restyle the surface. */
.dialog {
  box-sizing: border-box; width: min(480px, calc(100vw - 32px)); max-width: calc(100vw - 16px); max-height: calc(100dvh - 32px);
  margin: auto; padding: 24px; overflow-y: auto; overscroll-behavior: contain;
  border: 1px solid var(--line); border-radius: var(--radius-panel); corner-shape: var(--corner-shape);
  background: var(--paper); color: var(--ink); box-shadow: var(--shadow-modal);
}
.dialog::backdrop { background: var(--backdrop); }
.dialog :is(.dialog-title, h2):first-child { margin: 0; font-size: var(--text-section); line-height: 1.5; font-weight: 600; overflow-wrap: anywhere; }
.dialog:not(.dialog-sections) > .dialog-body { margin-top: 8px; color: var(--muted); overflow-wrap: anywhere; }
.dialog-body > :is(p, ul) { margin: 0; }
.dialog-body > * + * { margin-top: 8px; }
.dialog-body ul { padding-left: 20px; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--control-gap); margin-top: 24px; }
.dialog-sections { padding: 0; }
.dialog-sections > .dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 24px; border-bottom: 1px solid var(--line); background: var(--paper); }
.dialog-sections > .dialog-head :is(h2, .dialog-title) { margin: 0; font-size: var(--text-section); }
.dialog-sections > .dialog-body { padding: 24px; }
@media (max-width: 599px) {
  .dialog { padding: 16px; }
  .dialog-actions > .button { flex: 1 1 auto; }
  .dialog-sections { padding: 0; }
  .dialog-sections > :is(.dialog-head, .dialog-body) { padding: 16px; }
}
@media (prefers-reduced-motion: no-preference) {
  .dialog[open] { animation: dialog-in var(--motion-base) var(--ease-standard); }
}
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px); } }
@media (forced-colors: active) { .dialog { border: 2px solid CanvasText; } }

/* Checkbox and radio rows (label.check) and bare boxes (.check-target, such as a table row's selection):
   native inputs drawn in CSS, without data: images. The 16px box sits on the first line of its label;
   :indeterminate draws the dash of a partial "select all". The label is the hit area. */
label.check {
  display: flex; align-items: flex-start; gap: var(--control-gap); min-height: 44px; padding-block: 10px;
  line-height: 1.5; cursor: pointer;
}
label.check:has(> input:disabled) { color: var(--muted); cursor: not-allowed; }
.check-target { display: inline-grid; flex: none; place-items: center; width: 44px; height: 44px; margin: 0; cursor: pointer; }
:is(label.check, .check-target) > input:is([type="checkbox"], [type="radio"]):where(:not(.switch)) {
  appearance: none; -webkit-appearance: none; display: inline-grid; flex: none; place-content: center;
  box-sizing: border-box; width: 16px; height: 16px; min-height: 0; margin: 0; padding: 0;
  border: 1.5px solid var(--control-line); border-radius: var(--radius-tag); background: var(--paper);
  color: var(--on-accent); font: inherit; cursor: pointer;
}
label.check > input:is([type="checkbox"], [type="radio"]) { margin-top: calc((1.5em - 16px) / 2); }
:is(label.check, .check-target) > input[type="radio"]:where(:not(.switch)) { border-radius: 50%; }
:is(label.check, .check-target) > input:is([type="checkbox"], [type="radio"]):where(:not(.switch))::before {
  content: ""; width: 10px; height: 10px; box-shadow: inset 1em 1em currentColor; transform: scale(0);
}
:is(label.check, .check-target) > input[type="checkbox"]:where(:not(.switch))::before { clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0, 43% 62%); }
:is(label.check, .check-target) > input[type="checkbox"]:where(:not(.switch)):indeterminate::before { clip-path: inset(40% 8%); }
:is(label.check, .check-target) > input[type="radio"]::before { width: 6px; height: 6px; border-radius: 50%; }
:is(label.check, .check-target) > input:is(:checked, [type="checkbox"]:indeterminate):where(:not(.switch)) { border-color: var(--accent); background: var(--accent); }
:is(label.check, .check-target) > input:is(:checked, [type="checkbox"]:indeterminate):where(:not(.switch))::before { transform: scale(1); }
@media (any-hover: hover) and (any-pointer: fine) {
  :where(:root:not([data-ui-hover="false"])) :is(label.check, .check-target):hover > input:is([type="checkbox"], [type="radio"]):where(:not(.switch, :checked, :indeterminate, :disabled)) {
    border-color: var(--muted);
  }
}
:is(label.check, .check-target):active > input:is([type="checkbox"], [type="radio"]):where(:not(.switch, :checked, :indeterminate, :disabled)) {
  background: var(--hover);
}
:is(label.check, .check-target) > input:is([type="checkbox"], [type="radio"]):focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset); }
:is(label.check, .check-target) > input:is([type="checkbox"], [type="radio"]):where(:not(.switch)):disabled { border-color: var(--line); background: var(--soft); cursor: not-allowed; }
:is(label.check, .check-target) > input:is(:checked, [type="checkbox"]:indeterminate):where(:not(.switch)):disabled { border-color: var(--faint); background: var(--faint); }

/* Switch (input.switch with type="checkbox" and role="switch"): a setting that takes effect at once.
   Put it in a label.check row and write the current state in a .switch-state beside it; turning off
   something with a cost still asks for a reason (§4). Choices that wait for a Save button stay checkboxes. */
input.switch[type="checkbox"] {
  appearance: none; -webkit-appearance: none; position: relative; flex: none; box-sizing: border-box;
  width: 36px; height: 20px; min-height: 0; margin: 0; padding: 0; border: 0; border-radius: 999px;
  background: var(--control-line); font: inherit; cursor: pointer;
}
label.check > input.switch { margin-top: calc((1.5em - 20px) / 2); }
input.switch[type="checkbox"]::before {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--paper); box-shadow: 0 1px 2px rgb(17 21 34 / .24);
}
input.switch[type="checkbox"]:checked { background: var(--accent); }
input.switch[type="checkbox"]:checked::before { background: var(--on-accent); transform: translateX(16px); }
@media (prefers-reduced-motion: no-preference) {
  input.switch[type="checkbox"]::before { transition: transform var(--motion-fast) var(--ease-standard); }
}
@media (any-hover: hover) and (any-pointer: fine) {
  :where(:root:not([data-ui-hover="false"])) label.check:hover > input.switch:where(:not(:checked, :disabled)) { background: var(--muted); }
  :where(:root:not([data-ui-hover="false"])) label.check:hover > input.switch:where(:checked:not(:disabled)) { background: var(--accent-hover); }
}
input.switch[type="checkbox"]:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset); }
input.switch[type="checkbox"]:disabled { background: var(--line); cursor: not-allowed; }
input.switch[type="checkbox"]:disabled::before { background: var(--soft); box-shadow: none; }
input.switch[type="checkbox"]:checked:disabled { background: var(--faint); }
input.switch[aria-busy="true"] { cursor: progress; }
input.switch[aria-busy="true"]::before { opacity: .55; }
.switch-state { color: var(--muted); font-size: var(--text-meta); line-height: calc(var(--text-body) * 1.5); }
@media (forced-colors: active) {
  :is(label.check, .check-target) > input:is([type="checkbox"], [type="radio"]), input.switch[type="checkbox"] { appearance: auto; -webkit-appearance: auto; }
  :is(label.check, .check-target) > input:is([type="checkbox"], [type="radio"])::before, input.switch[type="checkbox"]::before { display: none; }
}

/* Chips (.chip, grouped in .chips): filter conditions, 常用原因 and removable tags. A capsule, 44px on touch
   and 32px under precision density. aria-pressed="true" marks a chosen filter; a 常用原因 chip is a complete
   sentence that only fills the reason field. A removable tag (.is-removable) is one button with a trailing
   close icon and an accessible name such as "移除筛选：…"; the whole chip removes it. */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-8); }
.chip {
  box-sizing: border-box; display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  min-height: 44px; margin: 0; padding: 8px 14px;
  border: 1px solid var(--button-line); border-radius: 999px; background: var(--paper); color: var(--ink);
  font: inherit; font-size: var(--text-meta); font-weight: 500; line-height: 1.35;
  text-align: start; text-decoration: none; overflow-wrap: anywhere;
}
:is(button, a).chip { cursor: pointer; }
@media (any-hover: hover) and (any-pointer: fine) {
  :where(:root:not([data-ui-hover="false"])) :is(button, a).chip:where(:not(:disabled, [aria-disabled="true"], [aria-pressed="true"])):hover {
    background: var(--hover); color: var(--ink); text-decoration: none;
  }
  :where(:root:not([data-ui-hover="false"])) .chip.is-removable:hover > svg { color: var(--ink); }
}
:is(button, a).chip:where(:not(:disabled, [aria-disabled="true"])):active { background: var(--line-soft); }
.chip[aria-pressed="true"] { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chip:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset); }
.chip:is(:disabled, [aria-disabled="true"]) { border-color: var(--line); background: var(--soft); color: var(--muted); cursor: not-allowed; }
.chip[aria-busy="true"] { color: var(--muted); cursor: progress; }
.chip > svg { flex: none; width: 16px; height: 16px; }
.chip.is-removable { padding-inline-end: 10px; }
.chip.is-removable > svg { width: 14px; height: 14px; color: var(--muted); }
@media (forced-colors: active) { .chip[aria-pressed="true"] { border: 2px solid Highlight; } }

/* Keyboard shortcut (kbd), beside a button or in a menu item, so shortcuts can be found (§4 高效操作). */
kbd {
  box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: var(--radius-tag); background: var(--soft); color: var(--ink-2);
  font: 500 11px/1 var(--font-num); font-variant-numeric: tabular-nums; white-space: nowrap; vertical-align: middle;
}
kbd + kbd { margin-inline-start: 2px; }

/* Meter (.meter): a thin bar for n / N, such as 筹备进度、缴费比例、名单完成度. Write the numbers beside it; the
   bar never carries them alone and stays out when the data is not reliable (§1). Each part is an <i> whose width
   the script sets through element.style (the page CSP forbids style attributes); .is-soft marks a pending part. */
.meter {
  position: relative; display: inline-block; flex: none; width: 96px; height: 4px; overflow: hidden;
  border-radius: var(--radius-tag); background: var(--line); vertical-align: middle;
}
.meter.is-wide { display: block; width: 100%; }
.meter > i { position: absolute; z-index: 1; inset-block: 0; inset-inline-start: 0; border-radius: inherit; background: var(--accent); }
.meter > i.is-soft { z-index: 0; background: var(--accent-line); }
.meter > i.is-good { background: var(--good); }
.meter > i.is-warn { background: var(--warn); }
@media (forced-colors: active) {
  .meter { border: 1px solid CanvasText; }
  .meter > i { background: Highlight; }
}

/* Selection bar (.selection-bar): takes the toolbar's place while rows are picked. .selection-count says how many,
   each action says how many it touches (§2), and the bar stays at the top while the list scrolls. */
.selection-bar {
  position: sticky; top: var(--space-8); z-index: var(--layer-sticky);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--control-gap) var(--space-16);
  min-height: 40px; padding: 4px 6px 4px 14px; border-radius: var(--radius-panel); corner-shape: var(--corner-shape);
  background: var(--sheet, var(--paper)); box-shadow: var(--shadow-sheet);
}
.selection-bar-lead { display: inline-flex; align-items: center; gap: var(--space-8); }
.selection-count { font-weight: 600; font-variant-numeric: tabular-nums; }
.selection-count > b { color: var(--accent); font: 600 var(--text-title)/1 var(--font-num); font-variant-numeric: tabular-nums; }
.selection-bar-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--control-gap); }

/* Tooltip: the short name of an icon-only button or of truncated text (installSharedControls in overlays.mjs).
   Mouse hover after a short delay or keyboard focus; never on touch; Escape, leaving or scrolling hides it.
   It holds no text people must read and nothing to click. */
.tooltip {
  position: fixed; z-index: var(--layer-toast); box-sizing: border-box; max-width: min(280px, calc(100vw - 16px));
  margin: 0; padding: 4px 8px; border-radius: var(--radius-item); background: var(--ink); color: var(--paper);
  font-size: var(--text-caption); font-weight: 500; line-height: 1.4; overflow-wrap: anywhere; pointer-events: none;
  box-shadow: var(--shadow-overlay);
}
.tooltip[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .tooltip { animation: tooltip-in var(--motion-fast) var(--ease-standard); }
}
@keyframes tooltip-in { from { opacity: 0; } }
@media (forced-colors: active) { .tooltip { border: 1px solid CanvasText; } }

/* Continuous corners are a shared shape, not a larger circular border radius.
   Browsers that support corner-shape paint superellipse corners natively; Safari,
   WeChat WKWebView and other engines without corner-shape paint standard border-radius
   backgrounds and borders directly on the host so async scrolling never drops layers. */
:where(.auth-card, .panel, .shell-tabs, .shell-account-menu) {
  position: relative;
  border-radius: var(--radius-panel); corner-shape: var(--corner-shape);
  background-color: var(--paper); border-color: var(--line);
}
:where(.button, .shell-tab, .shell-nav-link, .shell-menu-item, .panel,
  input:not([type="checkbox"], [type="radio"], [type="range"], [type="file"]), textarea, select) {
  corner-shape: var(--corner-shape);
}
:where(.icon-button, .voice-button, .voice-choice, .voice-cancel, [data-ui-shape="round"]) { corner-shape: round; }

/* Inline edit fields (.inline-fields > .inline-field): a label and value list that is edited in place (§1 直接操作).
   A row is a label and its own control (an input, select or textarea, or one inside a .select-shell or .date-field),
   written as <div class="inline-field"><label for>…</label>control</div> or as <label class="inline-field">text control</label>.
   A row with several controls puts a .inline-field-label beside a .inline-field-value, and those controls keep their frames.
   A .inline-field-note after the control (or inside the value) is a line under the value: a description or a warning.
   From 600px the label sits to the left. Under precision density (a mouse, 600px up) text and date controls read as
   plain text while enabled selects keep a compact width with a faint caret; hovering shows an underline (darkening the
   caret or revealing the calendar button), and focus shows the usual field. On touch and phones it stays a boxed
   field. Disabled controls (a read-only event, a save in progress) read as plain text without a caret. */
.inline-fields { display: grid; min-width: 0; margin: 0 0 var(--space-8); }
.inline-fields > .inline-field { display: grid; gap: var(--space-4); min-width: 0; margin: 0; padding: var(--space-8) 0; }
.inline-fields > .inline-field > :is(label, .inline-field-label),
.inline-fields > label.inline-field { margin: 0; color: var(--muted); font-size: var(--text-meta); font-weight: 500; }
.inline-fields > .inline-field > :is(input, textarea)::placeholder { color: var(--muted); font-weight: 400; }
.inline-field-value { min-width: 0; }
/* A note under the value (a description, an example, a warning) sits in the value column, as its own line. */
.inline-fields > .inline-field > .inline-field-note,
.inline-field-value > .inline-field-note { display: block; margin: 0; color: var(--muted); font-size: var(--text-meta); font-weight: 400; line-height: 1.5; }
@media (min-width: 600px) {
  /* Two columns on the text baseline (the label column in label-size units, the same whichever element is the row),
     hairlines between rows; a phone stacks label over a boxed field and needs no lines. */
  .inline-fields > .inline-field {
    grid-template-columns: minmax(88px, calc(10.5 * var(--text-meta))) minmax(0, 1fr); align-items: baseline; column-gap: var(--space-24); border-bottom: 1px solid var(--line-soft);
  }
  .inline-fields > .inline-field:last-child { border-bottom: 0; }
  .inline-fields > .inline-field > :is(.inline-field-note, .inline-error) { grid-column: 2; }
}
@media (min-width: 600px) and (pointer: fine) {
  [data-density="precise"] .inline-fields > .inline-field { padding-block: var(--space-4); }
  /* The value's text lines up with the column; the frame, when it shows, reaches into the gap. */
  [data-density="precise"] .inline-field > :is(
    input:not([type="checkbox"], [type="radio"]),
    textarea,
    .date-field
  ) {
    width: calc(100% + var(--control-pad-inline)); max-width: none;
    margin-inline-start: calc(-1 * var(--control-pad-inline));
  }
  /* 原位下拉按当前选项文字宽度自适应收缩，使静默微箭头紧贴所选文字；聚焦外框左伸进列距以保持文字零位移。 */
  [data-density="precise"] .inline-field > :is(select, .select-shell) {
    width: fit-content; max-width: calc(100% + var(--control-pad-inline)); justify-self: start;
    margin-inline-start: calc(-1 * var(--control-pad-inline));
  }
  [data-density="precise"] .inline-field > select { field-sizing: content; }
  [data-density="precise"] .inline-field > .select-shell > select {
    field-sizing: content; width: fit-content; max-width: 100%;
  }
  /* A note reads as its own lines; it grows while being written (where field-sizing is supported). */
  [data-density="precise"] .inline-field > textarea { field-sizing: content; min-height: var(--control-height); resize: none; }
  [data-density="precise"] .inline-field > textarea:focus { min-height: calc(4lh + 2 * var(--control-pad-block)); }
  [data-density="precise"] :is(
    .inline-field > :is(input:not([type="checkbox"], [type="radio"]), select, textarea),
    .inline-field > :is(.select-shell, .date-field) > :is(input, select)
  ):not(:focus, [data-select-menu-open="true"]) {
    border-color: transparent; border-radius: 0; background-color: transparent; box-shadow: none;
  }
  /* 可用的原位下拉在静默态保留贴字微箭头，悬停或聚焦/展开时加深为标准箭头，禁用态不显箭头。 */
  [data-density="precise"] :is(
    .inline-field > select,
    .inline-field > .select-shell > select
  ):not(:focus, :disabled, [data-select-menu-open="true"]) {
    background-image: var(--control-select-icon-faint) !important;
  }
  [data-density="precise"] .inline-field > select:disabled,
  [data-density="precise"] .inline-field > .select-shell > select:disabled {
    background-image: none !important;
  }
  /* 静默态隐藏日期图标；真实鼠标悬停由下方双门控规则显现，避免触屏粘滞 :hover。 */
  [data-density="precise"] .inline-field:not(:focus-within) > .date-field > .date-field-trigger { opacity: 0; }
  [data-density="precise"] .inline-field > .date-field > .date-field-trigger:disabled { visibility: hidden; }
  [data-density="precise"] :is(
    .inline-field > :is(input, select, textarea),
    .inline-field > :is(.select-shell, .date-field) > :is(input, select)
  ):disabled {
    color: var(--ink-2); -webkit-text-fill-color: var(--ink-2); opacity: 1; cursor: default;
  }
}
@media (min-width: 600px) and (pointer: fine) and (any-hover: hover) and (any-pointer: fine) {
  :where(:root:not([data-ui-hover="false"])) [data-density="precise"] .inline-field:hover > .date-field > .date-field-trigger {
    opacity: 1;
  }
  :where(:root:not([data-ui-hover="false"])) [data-density="precise"] :is(
    .inline-field:hover > :is(input:not([type="checkbox"], [type="radio"]), select, textarea),
    .inline-field:hover > :is(.select-shell, .date-field) > :is(input, select)
  ):not(:focus, :disabled, [readonly], [data-select-menu-open="true"]) {
    box-shadow: inset 0 -1px 0 var(--control-line);
  }
  :where(:root:not([data-ui-hover="false"])) [data-density="precise"] :is(
    .inline-field:hover > select,
    .inline-field:hover > .select-shell > select
  ):not(:focus, :disabled, [data-select-menu-open="true"]) {
    background-image: var(--control-select-icon) !important;
  }
}

/* 原位底线输入（.inline-field.is-underline，规范 §4）：
   用于原位备注/依据行等轻量化文本输入；无四边外框、左缘与下方说明及 .reason-links 严格对齐，
   悬停显 1px 发丝底线，聚焦仅现 2px 品牌底线而不冒出四边框或默认 outline。 */
.inline-fields > .inline-field.is-underline > :is(input:not([type="checkbox"], [type="radio"]), textarea),
[data-density="precise"] .inline-fields > .inline-field.is-underline > :is(input:not([type="checkbox"], [type="radio"]), textarea) {
  box-sizing: border-box; width: 100%; max-width: 100%; margin-inline-start: 0;
  padding-inline: 0; padding-block: var(--control-pad-block);
  border: 0; border-radius: 0; background-color: transparent; color: var(--ink);
  font: inherit; font-size: var(--text-input); line-height: 1.4;
  outline: none; box-shadow: none;
}
.inline-fields > .inline-field.is-underline > :is(input:not([type="checkbox"], [type="radio"]), textarea):focus,
[data-density="precise"] .inline-fields > .inline-field.is-underline > :is(input:not([type="checkbox"], [type="radio"]), textarea):focus {
  border: 0; border-radius: 0; background-color: transparent; outline: none;
  box-shadow: inset 0 -2px 0 var(--focus);
}
.inline-fields > .inline-field.is-underline > :is(input:not([type="checkbox"], [type="radio"]), textarea)[aria-invalid="true"],
[data-density="precise"] .inline-fields > .inline-field.is-underline > :is(input:not([type="checkbox"], [type="radio"]), textarea)[aria-invalid="true"] {
  box-shadow: inset 0 -2px 0 var(--danger);
}
.inline-fields > .inline-field.is-underline > :is(input:not([type="checkbox"], [type="radio"]), textarea):disabled,
[data-density="precise"] .inline-fields > .inline-field.is-underline > :is(input:not([type="checkbox"], [type="radio"]), textarea):disabled {
  box-shadow: none; color: var(--ink-2); -webkit-text-fill-color: var(--ink-2); opacity: 1; cursor: default;
}
@media (max-width: 599px), (pointer: coarse) {
  .inline-fields > .inline-field.is-underline > :is(input:not([type="checkbox"], [type="radio"]), textarea):not(:focus, :disabled, [aria-invalid="true"]) {
    box-shadow: inset 0 -1px 0 var(--line);
  }
}
@media (any-hover: hover) and (any-pointer: fine) {
  :where(:root:not([data-ui-hover="false"]))
  .inline-fields > .inline-field.is-underline:hover
  > :is(input:not([type="checkbox"], [type="radio"]), textarea):not(:focus, :disabled, [readonly], [aria-invalid="true"]) {
    box-shadow: inset 0 -1px 0 var(--control-line);
  }
}
@media (forced-colors: active) {
  .inline-fields > .inline-field.is-underline > :is(input:not([type="checkbox"], [type="radio"]), textarea) {
    border-bottom: 1px solid CanvasText;
  }
  .inline-fields > .inline-field.is-underline > :is(input:not([type="checkbox"], [type="radio"]), textarea):focus {
    border-bottom: 2px solid Highlight; outline: 2px solid Highlight; outline-offset: 2px;
  }
}
@media (min-width: 600px) {
  .inline-fields > .inline-field.is-top { align-items: baseline; }
}

/* 原位轻链常用原因（.reason-links，规范 §4）：位于原位输入值正下方，无描边胶囊框，左缘严格对齐输入文字。 */
.reason-links {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px;
  margin-top: 2px; font-size: var(--text-caption); color: var(--muted); line-height: 1.5;
}
.reason-links-label { color: var(--muted); user-select: none; }
.reason-link {
  box-sizing: border-box; display: inline-flex; align-items: center;
  min-height: 28px; margin: 0; padding: 2px 0; border: 0; border-radius: var(--radius-tag);
  background: transparent; color: var(--accent);
  font: inherit; font-size: var(--text-caption); font-weight: 500; text-align: start; cursor: pointer;
}
@media (max-width: 599px), (pointer: coarse) {
  .reason-link { min-height: 36px; padding: 6px 2px; }
}
@media (any-hover: hover) and (any-pointer: fine) {
  :where(:root:not([data-ui-hover="false"])) .reason-link:hover {
    color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px;
  }
}
.reason-link:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: 2px; }

/* Precision density on fine pointers from 600px upward: 36px/32px controls, touch & voice stay 44px. */
@media (min-width: 600px) and (pointer: fine) {
  [data-density="precise"] .button { padding: 6px 14px; }
  [data-density="precise"] .button.small,
  [data-density="precise"] .button.text { min-height: 32px; padding: 4px 12px; font-size: var(--text-meta); }
  [data-density="precise"] .button.text { min-width: 24px; padding-inline: 8px; }
  [data-density="precise"] :where(.button).icon-button.small { width: 32px; min-width: 32px; height: 32px; padding: 0; }
  [data-density="precise"] .segmented > :is(button, a) { min-height: 32px; }
  [data-density="precise"] .shell-tabs.is-line > .shell-tab { min-height: 38px; }
  [data-density="precise"] .menu-item,
  [data-density="precise"] .select-menu-option { min-height: 34px; padding-block: 6px; }
  [data-density="precise"] label.check { min-height: 34px; padding-block: 6px; }
  [data-density="precise"] .chip { min-height: 32px; padding: 4px 12px; }
  [data-density="precise"] .chip.is-removable { padding-inline-end: 8px; }
  [data-density="precise"] .check-target { width: 32px; height: 32px; }
  /* 精密工作台密度下适当收紧提示条纵向留白，与 36px 控件高度协调。 */
  [data-density="precise"] .notice { padding-block: var(--space-8); }
  [data-density="precise"] .notice :is(.actions, .button-row) { margin-top: var(--space-8); }
  /* Icons come in two sizes: 20px, and 16px on the 32px controls of precision density, with a heavier stroke. */
  [data-density="precise"] :is(.button.small, .button.text, .icon-button.small, .chip) > svg { width: 16px; height: 16px; stroke-width: 2.1; }
  [data-density="precise"] :where(
    select:not([multiple], [size]),
    input:is(:not([type]), [type="text"], [type="search"], [type="password"], [type="email"], [type="tel"], [type="url"], [type="number"]),
    input:is([type="date"], [type="time"], [type="datetime-local"], [type="month"], [type="week"])
  ) { --control-pad-block: 5px; }
  [data-density="precise"] :is(.voice-button, .voice-choice, .voice-cancel),
  [data-density="precise"] .assistant-workspace .composer button { min-height: 44px; }
}

/* Date only: the named text input and its calendar button share one field. */
.date-field { display: block; position: relative; min-width: 0; max-width: 100%; }
.date-field > input[type="text"] {
  box-sizing: border-box; width: 100%; min-width: 0; min-height: var(--control-height); padding-inline-end: calc(var(--control-height) + var(--space-4));
  font-size: var(--text-input); font-variant-numeric: tabular-nums;
}
.date-field > .date-field-trigger {
  position: absolute; inset-block: 0; inset-inline-end: 0; display: grid; place-items: center; width: var(--control-height); min-height: var(--control-height);
  margin: 0; padding: 0; border: 0; border-radius: var(--control-radius); background: transparent; color: var(--muted); cursor: pointer;
}
.date-field-trigger:disabled { cursor: default; opacity: .55; }
.date-field-trigger:focus-visible, .date-calendar [data-day]:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: -3px; }
.date-calendar {
  box-sizing: border-box; width: min(384px, 100%); max-width: 100%; padding: clamp(4px, calc((100vw - 318px) / 2), 16px);
  font: inherit; text-align: start; color: var(--ink);
}
.date-calendar-popover {
  position: fixed; inset: auto; z-index: var(--layer-dropdown); margin: 0;
  max-width: calc(100vw - var(--space-32)); overflow: auto; overscroll-behavior: contain;
  border: 1px solid var(--line); border-radius: var(--radius-panel); corner-shape: var(--corner-shape);
  background: var(--paper); box-shadow: var(--shadow-overlay);
}
.date-calendar-head, .date-calendar-actions { display: flex; align-items: center; justify-content: space-between; gap: var(--control-gap); }
.date-calendar-head { margin-bottom: 4px; }
.date-calendar-head .icon-button { font-size: 24px; }
.date-calendar-actions { margin-top: 8px; }
.date-calendar table { width: 100%; table-layout: fixed; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.date-calendar :is(th, td) { padding: 0; border: 0; text-align: center; }
.date-calendar th { height: 32px; font-size: var(--text-meta); font-weight: 500; color: var(--muted); }
.date-calendar [data-day] {
  display: block; width: 100%; min-height: 44px; margin: 0; padding: 0; border: 0; border-radius: var(--radius-item);
  background: transparent; color: var(--ink); font: inherit; font-size: var(--text-input); cursor: pointer;
}
.date-calendar [aria-current="date"] { text-decoration: underline; text-underline-offset: 4px; }
.date-calendar [aria-selected="true"] > button { background: var(--accent); color: var(--on-accent); }
@media (any-hover: hover) and (any-pointer: fine) {
  :where(:root:not([data-ui-hover="false"])) .date-calendar [aria-selected="false"] > button:hover { background: var(--hover); }
}

/* 24h time field mirrors .date-field height, border, and popover ergonomics without native WebKit wheels. */
.time-field { display: block; position: relative; min-width: 0; max-width: 100%; }
.time-field > input[type="text"] {
  box-sizing: border-box; width: 100%; min-width: 0; min-height: var(--control-height); height: var(--control-height);
  padding-inline-end: calc(var(--control-height) + var(--space-4));
  font-size: var(--text-input); font-variant-numeric: tabular-nums;
}
.time-field > .time-field-trigger {
  position: absolute; inset-block: 0; inset-inline-end: 0; display: grid; place-items: center;
  width: var(--control-height); min-height: var(--control-height);
  margin: 0; padding: 0; border: 0; border-radius: var(--control-radius); background: transparent; color: var(--muted); cursor: pointer;
}
.time-field-trigger:disabled { cursor: default; opacity: .55; }
.time-field-trigger:focus-visible, .time-picker-option:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: -3px; }
.time-picker-popover {
  position: fixed; z-index: var(--layer-dropdown); box-sizing: border-box; width: min(272px, calc(100vw - 24px));
  max-width: calc(100vw - 24px); padding: 12px; display: grid; gap: 10px;
  border: 1px solid var(--line); border-radius: var(--radius-panel); corner-shape: var(--corner-shape);
  background: var(--paper); box-shadow: var(--shadow-overlay);
  color: var(--ink);
}
.time-picker-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; }
.time-picker-cols { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; min-width: 0; }
.time-picker-col { display: grid; align-content: start; gap: 6px; min-width: 0; }
.time-picker-col-label { font-size: var(--text-caption); font-weight: 600; color: var(--muted); }
.time-picker-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; max-height: 220px; overflow-y: auto; overscroll-behavior: contain; }
.time-picker-grid.is-minutes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.time-picker-option {
  min-height: 32px; min-width: 0; padding: 4px; border: 1px solid transparent; border-radius: var(--radius-item);
  background: transparent; color: var(--ink); font: inherit; font-size: 13px; cursor: pointer; text-align: center;
}
@media (max-width: 599px), (pointer: coarse) {
  .time-picker-option { min-height: 44px; font-size: 14px; }
}
@media (any-hover: hover) and (any-pointer: fine) {
  :where(:root:not([data-ui-hover="false"])) .time-picker-option[aria-pressed="false"]:hover { background: var(--hover); }
}
.time-picker-option[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.time-picker-actions { display: flex; justify-content: flex-end; }

/* Numbered steps share their 24px mark with the design reference. */
.ds-step-mark {
  box-sizing: border-box; display: grid; place-items: center; flex: none; width: 24px; height: 24px;
  border: 1px solid var(--control-line); border-radius: 50%; color: var(--muted); font-size: 12px; line-height: 1; font-variant-numeric: tabular-nums;
}
.ds-step-mark svg { display: block; width: 14px; height: 14px; color: currentColor; }
.ds-step-mark .ds-step-digit { width: 22px; height: 22px; fill: currentColor; }
.ds-step[data-status="complete"] .ds-step-mark { border-color: var(--good-line); background: var(--good-soft); color: var(--good); }
.ds-step[aria-current="step"] .ds-step-mark { border-color: var(--accent); color: var(--accent); }
