/* TwinMind Studio /ui.
   Design contract: a quiet, high-craft local workbench in the Vercel / Linear manner.
   Three props: (1) radius 6px everywhere (8px for cards/dialogs), never pill-shaped primary buttons; (2) depth = 1px hairline
   borders and one background step, no decorative shadows except floating toast/dialog; (3) ONE accent (blue) for primary focus,
   links, active filter chips and the "on" state of switches. Status colours (green/amber/red) appear only as dots, chips,
   verdict left-border accents and quota meters.
   Type: 13/14px body, weight for hierarchy, tabular-nums for all metrics; spacing on a 4/8 grid; motion 150-200ms ease-out.
   Themes (设置 → 本页 → 主题): 纸白 (default light), 米白 (warm light), 青雾 (sage light), 夜 (dark); 跟随系统 picks 纸白 / 夜. */

:root {
  --bg: #f6f5f1; --surface: #ffffff; --surface-2: #f0eee8; --border: #e3dfd6; --border-strong: #847f73;
  --fg: #1a211e; --fg-2: #444d49; --muted: #5b6560;
  --accent: #1d6a50; --accent-hover: #175641; --accent-fg: #ffffff; --accent-soft: #e3efe8;
  --ok: #166534; --warn: #8a5200; --err: #b42318;
  --ok-dot: #166534; --warn-dot: #b45309; --err-dot: #b42318;
  --fg-on-status: #ffffff;
  --toast-bg: #1a211e; --toast-text: #f6f5f1; --toast-action-bg: rgba(255, 255, 255, .14); --toast-action-border: rgba(255, 255, 255, .28);
  --rec: #c2362b; --rec-soft: #fdecea; --wave-idle: #c7c2b6; --wave-rec: #c2362b; --wave-live: #1d6a50;
  --focus: #1d6a50;
  --radius-sm: 6px; --radius: 10px; --radius-lg: 14px; --radius-xl: 18px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px;
  --fs-xs: 0.75rem; --fs-sm: 0.8125rem; --fs-base: 0.875rem; --fs-md: 1rem; --fs-lg: 1.25rem; --fs-time: 1.75rem;
  --shadow-1: 0 1px 2px rgb(20 24 22 / .04), 0 1px 3px rgb(20 24 22 / .03);
  --shadow-card: 0 1px 2px rgb(20 24 22 / .05), 0 4px 12px -4px rgb(20 24 22 / .06);
  --shadow-sm: 0 6px 24px rgba(20, 24, 22, .14);
  --shadow-lg: 0 18px 48px rgba(20, 24, 22, .20);
  --side-w: 212px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, 0, 0, 1);
  color-scheme: light;
}
:root[data-theme="linen"] {
  --bg: #f8f4ec; --surface: #fffdf9; --surface-2: #f1ebe0; --border: #e6dcc9; --border-strong: #8a7e6b;
  --fg: #2a2117; --fg-2: #584b3a; --muted: #685c49; --accent: #9c4c17; --accent-hover: #823e12; --accent-soft: #f7e8da;
  --ok: #3f6d2a; --warn: #9a4708; --err: #b42318; --ok-dot: #3f6d2a; --warn-dot: #9a4708; --err-dot: #b42318; --focus: #9c4c17;
  --toast-bg: #2a2117; --toast-text: #f8f4ec;
  --wave-idle: #d4c7af; --wave-live: #9c4c17;
}
:root[data-theme="sage"] {
  --bg: #f2f6f4; --surface: #fbfdfc; --surface-2: #e7efeb; --border: #d5e2dc; --border-strong: #73837b;
  --fg: #16211c; --fg-2: #384a41; --muted: #526159; --accent: #1a664b; --accent-hover: #14523c; --accent-soft: #dff0e8;
  --ok: #146c38; --warn: #8a4d08; --err: #b41d1d; --ok-dot: #146c38; --warn-dot: #8a4d08; --err-dot: #b41d1d; --focus: #1a664b;
  --toast-bg: #16211c; --toast-text: #f2f6f4;
  --wave-idle: #b8c9c1; --wave-live: #1a664b;
}
:root[data-theme="night"] {
  --bg: #111413; --surface: #181c1b; --surface-2: #1f2422; --border: #2a312e; --border-strong: #6c7671;
  --fg: #e8ecea; --fg-2: #b4bcb8; --muted: #9ca5a0;
  --accent: #5cc198; --accent-hover: #74d0aa; --accent-fg: #0a1712; --accent-soft: #1c372c;
  --ok: #5cc198; --warn: #f0b85b; --err: #ff8a7f;
  --ok-dot: #5cc198; --warn-dot: #f0b85b; --err-dot: #ff8a7f; --fg-on-status: #0e1110;
  --toast-bg: #e8ecea; --toast-text: #151918; --toast-action-bg: rgba(0, 0, 0, .09); --toast-action-border: rgba(0, 0, 0, .2);
  --focus: #8fe0be;
  --rec: #ff6f62; --rec-soft: #3a1c1a; --wave-idle: #3a423f; --wave-rec: #ff7a6e; --wave-live: #5cc198;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg: #111413; --surface: #181c1b; --surface-2: #1f2422; --border: #2a312e; --border-strong: #6c7671;
    --fg: #e8ecea; --fg-2: #b4bcb8; --muted: #9ca5a0;
    --accent: #5cc198; --accent-hover: #74d0aa; --accent-fg: #0a1712; --accent-soft: #1c372c;
    --ok: #5cc198; --warn: #f0b85b; --err: #ff8a7f;
    --ok-dot: #5cc198; --warn-dot: #f0b85b; --err-dot: #ff8a7f; --fg-on-status: #0e1110;
    --toast-bg: #e8ecea; --toast-text: #151918; --toast-action-bg: rgba(0, 0, 0, .09); --toast-action-border: rgba(0, 0, 0, .2);
    --focus: #8fe0be;
    --rec: #ff6f62; --rec-soft: #3a1c1a; --wave-idle: #3a423f; --wave-rec: #ff7a6e; --wave-live: #5cc198;
    color-scheme: dark;
  }
}
:root[data-theme-switching] *, :root[data-theme-switching] *::before, :root[data-theme-switching] *::after { transition: none !important; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: var(--fs-base)/1.55 var(--font); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
.mono, code, pre { font-family: var(--mono); font-size: var(--fs-xs); }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
/* a11y: a keyboard user can jump over the navigation; the link only shows while focused */
.skip { position: absolute; left: var(--sp-2); top: var(--sp-2); z-index: 50; padding: 6px 10px; border-radius: var(--radius); background: var(--fg); color: var(--bg); font-size: var(--fs-sm); transform: translateY(-200%); }
.skip:focus { transform: none; text-decoration: none; }
main:focus { outline: none; }

/* icons */
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
i[data-icon] { display: inline-flex; width: 17px; height: 17px; flex: none; align-items: center; justify-content: center; }
i[data-icon] svg, .ic { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
i[data-icon].ic-sm, i[data-icon].date-chevron { width: 14px; height: 14px; }
i[data-icon].ic-sm svg, i[data-icon].date-chevron svg { width: 14px; height: 14px; }

/* loading skeleton */
.skeleton {
  display: block; height: 14px; border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
}
.skeleton-stack { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-2) 0; }
.skeleton-card { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow-card); }
.skeleton-line { height: 13px; border-radius: var(--radius-sm); }
.skeleton-line.w-40 { width: 40%; }
.skeleton-line.w-70 { width: 70%; }
.skeleton-line.w-90 { width: 90%; }
@media (prefers-reduced-motion: no-preference) {
  .skeleton { animation: shimmer 1.4s infinite var(--ease); }
  .view { animation: fade .16s var(--ease); }
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* shell */
.app { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100dvh; }
.side {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: var(--sp-1);
  padding: var(--sp-4) 10px var(--sp-3); border-right: 1px solid var(--border); background: var(--bg);
}
.brand { display: flex; align-items: center; gap: 9px; padding: 2px 10px 14px; font-weight: 600; font-size: var(--fs-base); letter-spacing: -.015em; }
.brand-badge {
  width: 28px; height: 28px; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}
.brand-mark { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 2.1; stroke-linecap: round; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a {
  position: relative; display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: var(--radius);
  color: var(--fg-2); font-size: var(--fs-sm); text-decoration: none; transition: background-color .15s var(--ease), color .15s var(--ease);
}
nav a i { color: var(--muted); transition: color .15s var(--ease); }
@media (hover: hover) { nav a:hover { background: var(--surface-2); color: var(--fg); text-decoration: none; } }
nav a[aria-current="page"] { background: var(--surface); color: var(--fg); font-weight: 600; box-shadow: var(--shadow-1), inset 0 0 0 1px var(--border); }
nav a[aria-current="page"]::before {
  content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; width: 2.5px; border-radius: 2px; background: var(--accent);
}
nav a[aria-current="page"] i { color: var(--accent); }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) 10px; border-top: 1px solid var(--border); font-size: var(--fs-xs); color: var(--muted); }

main { min-width: 0; padding: 0 28px 52px; }
.bar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  height: 56px; margin: 0 -28px 14px; padding: 0 28px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid var(--border); backdrop-filter: saturate(1.4) blur(10px);
}
.bar-title-wrap { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex: 1; }
.bar h1 { margin: 0; font-size: var(--fs-lg); font-weight: 650; letter-spacing: -.02em; line-height: 1.25; white-space: nowrap; text-wrap: balance; }
.bar-sub { font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.kbd-hint { font-size: var(--fs-xs); color: var(--muted); display: inline-flex; align-items: center; gap: var(--sp-1); margin-right: var(--sp-1); }
kbd {
  display: inline-flex; align-items: center; justify-content: center; padding: 1px 5px; font: 500 var(--fs-xs)/1.3 var(--mono); color: var(--fg-2);
  background: var(--surface); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px;
}
.view { max-width: 1080px; padding-top: var(--sp-1); }
@keyframes fade { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }

/* status */
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); flex: none; }
.dot.ok { background: var(--ok-dot); box-shadow: 0 0 0 2px color-mix(in srgb, var(--ok-dot) 18%, transparent); }
.dot.warn { background: var(--warn-dot); box-shadow: 0 0 0 2px color-mix(in srgb, var(--warn-dot) 18%, transparent); }
.dot.err { background: var(--err-dot); box-shadow: 0 0 0 2px color-mix(in srgb, var(--err-dot) 18%, transparent); }
.pill {
  display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 10px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--surface); font-size: var(--fs-xs); color: var(--fg-2); white-space: nowrap;
}
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: var(--fs-xs); font-weight: 500; background: var(--surface-2); color: var(--fg-2); border: 1px solid var(--border); white-space: nowrap;
}
.chip.ok { color: var(--ok); background: color-mix(in srgb, var(--ok-dot) 10%, var(--surface)); border-color: color-mix(in srgb, var(--ok-dot) 28%, var(--border)); }
.chip.warn { color: var(--warn); background: color-mix(in srgb, var(--warn-dot) 10%, var(--surface)); border-color: color-mix(in srgb, var(--warn-dot) 30%, var(--border)); }
.chip.err { color: var(--err); background: color-mix(in srgb, var(--err-dot) 10%, var(--surface)); border-color: color-mix(in srgb, var(--err-dot) 30%, var(--border)); }
.chip.accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); background: var(--accent-soft); }

/* buttons & inputs */
button, select, input, textarea { font: inherit; color: inherit; }
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--fg);
  cursor: pointer; font-size: var(--fs-sm); font-weight: 500; white-space: nowrap; touch-action: manipulation;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), opacity .15s var(--ease);
}
@media (prefers-reduced-motion: no-preference) {
  button { transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), opacity .15s var(--ease), transform .15s var(--ease); }
  button:not(:disabled):active { transform: scale(.96); }
}
@media (hover: hover) { button:not(:disabled):hover { background: var(--surface-2); border-color: var(--border-strong); } }
button.ghost-sm { height: 28px; padding: 0 9px; font-size: var(--fs-xs); color: var(--fg-2); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
@media (hover: hover) { button.primary:not(:disabled):hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-fg); } }
button.btn-quiet { background: transparent; border-color: transparent; color: var(--fg-2); }
@media (hover: hover) { button.btn-quiet:not(:disabled):hover { background: var(--surface-2); border-color: transparent; color: var(--fg); } }
button.btn-soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
@media (hover: hover) { button.btn-soft:not(:disabled):hover { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); border-color: transparent; color: var(--accent); } }
button.danger-ghost { color: var(--err); border-color: color-mix(in srgb, var(--err-dot) 32%, var(--border)); }
@media (hover: hover) { button.danger-ghost:not(:disabled):hover { background: color-mix(in srgb, var(--err-dot) 8%, var(--surface)); } }
.select-sm { height: 28px; padding: 0 var(--sp-2); font-size: var(--fs-xs); color: var(--fg-2); }
.more-btn { margin-top: var(--sp-2); width: 100%; }
.icon-btn { width: 32px; padding: 0; border-color: transparent; background: transparent; color: var(--fg-2); }
@media (hover: hover) { .icon-btn:not(:disabled):hover { background: var(--surface-2); border-color: transparent; color: var(--fg); } }
.icon-btn.sm { width: 28px; height: 28px; border-color: transparent; background: transparent; color: var(--muted); }
@media (hover: hover) { .icon-btn.sm:not(:disabled):hover { background: var(--surface-2); color: var(--fg); } }
.link-btn { min-height: 28px; height: auto; padding: 2px 6px; border: 0; background: none; color: var(--accent); font-weight: 500; font-size: var(--fs-xs); }
.th-sort-btn { height: auto; padding: 2px 4px; border: 0; background: none; color: inherit; font: inherit; font-weight: 500; }
@media (hover: hover) { .link-btn:hover, .th-sort-btn:hover { background: none; text-decoration: underline; color: var(--fg); } }
.link-sm { font-size: var(--fs-xs); font-weight: 500; }
.row-tight { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
input[type=text], input[type=password], input[type=search], input[type=number], textarea, select {
  height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface);
  font-size: var(--fs-sm); transition: border-color .15s var(--ease);
}
textarea { height: auto; padding: var(--sp-2) 10px; resize: vertical; font-family: var(--font); font-size: var(--fs-base); line-height: 1.6; width: 100%; }
textarea.mono { font-family: var(--mono); font-size: var(--fs-xs); }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
label, .field > label { font-size: var(--fs-xs); font-weight: 500; color: var(--fg-2); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; color: var(--fg-2); font-size: var(--fs-sm); cursor: pointer; user-select: none; }
.check input { width: 15px; height: 15px; accent-color: var(--accent); margin: 0; }
.row { display: flex; gap: var(--sp-2); align-items: center; }
.row input { flex: 1; min-width: 0; }
.hint { color: var(--muted); font-size: var(--fs-xs); margin: 10px 0 0; line-height: 1.5; }
.form-err {
  color: var(--err); font-size: var(--fs-sm); margin: var(--sp-2) 0 0; padding: var(--sp-2) var(--sp-3);
  border: 1px solid color-mix(in srgb, var(--err-dot) 32%, var(--border)); border-radius: var(--radius);
  background: color-mix(in srgb, var(--err-dot) 6%, var(--surface)); white-space: pre-wrap;
}
.empty { color: var(--muted); font-size: var(--fs-sm); margin: 10px 0; }

/* filter pills */
.filter-pills { display: inline-flex; align-items: center; gap: var(--sp-1); flex-wrap: wrap; }
.filter-pill {
  height: 28px; padding: 0 10px; font-size: var(--fs-xs); font-weight: 500; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface); color: var(--fg-2);
}
.filter-pill:hover { background: var(--surface-2); color: var(--fg); }
.filter-pill[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}

/* switch */
button:disabled { opacity: .5; cursor: not-allowed; }
.switch {
  position: relative; width: 34px; height: 20px; padding: 0; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface-2); flex: none;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--fg-2); transition: background-color .15s var(--ease);
}
@media (prefers-reduced-motion: no-preference) {
  .switch::after { transition: transform .18s var(--ease), background-color .15s var(--ease); }
  .tile { transition: border-color .15s var(--ease), background-color .15s var(--ease), transform .12s var(--ease); }
  @media (hover: hover) { .tile:hover { transform: translateY(-1px); } }
  .toast { animation: toast-in .18s var(--ease); }
}
.switch[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(14px); background: var(--accent-fg); box-shadow: none; }
@media (hover: hover) {
  .switch:hover { background: var(--surface-2); }
  .switch[aria-checked="true"]:hover { background: var(--accent-hover); }
  .filter-pill:hover { background: var(--surface-2); color: var(--fg); }
  .tile:hover { background: var(--surface); border-color: var(--border-strong); }
}
.switch:active { transform: none; }

/* overview & B-002 3-step onboarding & client helper */
.verdict {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-4) 18px;
  border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--radius-lg); background: var(--surface);
  box-shadow: var(--shadow-card); transition: border-color .15s var(--ease);
}
.verdict.ok { border-left-color: var(--ok-dot); }
.verdict.warn { border-left-color: var(--warn-dot); }
.verdict.err { border-left-color: var(--err-dot); }
.verdict-title { font-size: var(--fs-md); font-weight: 600; letter-spacing: -.01em; display: flex; align-items: center; gap: 9px; }
.verdict-sub { margin-top: 3px; font-size: var(--fs-sm); }
.verdict-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.verdict-actions:empty { display: none; }
.connect { margin-top: var(--sp-3); padding: var(--sp-4) 18px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.connect label { display: block; margin-bottom: 6px; }
.onboard-steps {
  list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3);
}
.onboard-step {
  padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg);
  display: flex; flex-direction: column; gap: 6px;
}
.onboard-step.done { border-color: color-mix(in srgb, var(--ok-dot) 35%, var(--border)); background: color-mix(in srgb, var(--ok-dot) 4%, var(--surface)); }
.ob-head { display: flex; align-items: center; gap: var(--sp-2); font-weight: 600; font-size: var(--fs-sm); }
.ob-num {
  width: 20px; height: 20px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; font-size: var(--fs-xs); font-weight: 600; color: var(--fg-2); flex: none;
}
.onboard-step.done .ob-num { background: var(--ok); border-color: var(--ok); color: var(--fg-on-status); }
.ob-body { font-size: var(--fs-xs); line-height: 1.5; flex: 1; }
.ob-acts { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-1); }

/* client integration helper */
.client-helper-body { display: flex; flex-direction: column; gap: var(--sp-2); }
.client-kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--sp-2); }
.client-kv {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
  padding: var(--sp-2) 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg);
  font-size: var(--fs-xs);
}
.client-kv-label { color: var(--muted); font-weight: 500; }
.client-kv-val { font-family: var(--mono); color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-code-wrap { position: relative; }
.client-code {
  margin: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); font-family: var(--mono); font-size: var(--fs-xs); line-height: 1.5;
  white-space: pre-wrap; word-break: break-all;
}

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-3); margin-top: var(--sp-3); }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px; height: auto; padding: 13px 15px; text-align: left;
  border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-card); font-weight: 400;
  transition: border-color .15s var(--ease), background-color .15s var(--ease), transform .12s var(--ease);
}
@media (hover: hover) { .tile:hover { background: var(--surface); border-color: var(--border-strong); transform: translateY(-1px); } }
.tile:active { transform: none; }
.tile-k { font-size: var(--fs-xs); color: var(--muted); font-weight: 500; }
.tile-v { font-size: var(--fs-lg); font-weight: 600; letter-spacing: -.015em; line-height: 1.35; font-variant-numeric: tabular-nums; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-s { font-size: var(--fs-xs); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel { margin-top: var(--sp-3); padding: 13px 16px 15px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-card); }
.panel-table { padding: 4px 16px 8px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-card); }
.panel-h { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); font-size: var(--fs-sm); font-weight: 600; margin-bottom: var(--sp-2); min-height: 26px; }
.panel-h-wrap { flex-wrap: wrap; }
.panel-tools { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.panel-note { font-weight: 400; font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.todo { list-style: none; margin: 0; padding: 0; }
.todo li { display: flex; align-items: flex-start; gap: 10px; padding: var(--sp-2) 0; border-top: 1px solid var(--border); font-size: var(--fs-sm); }
.todo li:first-child { border-top: 0; padding-top: 2px; }
.todo li .dot { margin-top: 7px; }
.todo li .todo-act { margin-left: auto; }
.honesty { margin: var(--sp-4) 2px 0; font-size: var(--fs-xs); color: var(--muted); }
.notices { max-width: 1120px; }
.notice { display: flex; align-items: center; gap: 10px; margin: var(--sp-2) 0 0; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font-size: var(--fs-sm); }
.notice .notice-act { margin-left: auto; height: 26px; }
.notice.warn { border-color: color-mix(in srgb, var(--warn-dot) 45%, var(--border)); }
.notice.err { border-color: color-mix(in srgb, var(--err-dot) 45%, var(--border)); }

/* tables & grouped turns (B-006) & sticky sortable headers */
.table-wrap { overflow-x: auto; max-height: 540px; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th {
  position: sticky; top: 0; z-index: 1; background: var(--surface);
  text-align: left; font-weight: 500; font-size: var(--fs-xs); color: var(--muted); padding: 7px 10px 7px 4px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--fg); }
td { padding: var(--sp-2) 10px var(--sp-2) 4px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr { transition: background-color .12s var(--ease); }
@media (hover: hover) { tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); } }
tr:last-child td { border-bottom: 0; }
tr.turn-group-row { cursor: pointer; background: color-mix(in srgb, var(--surface-2) 45%, var(--surface)); font-weight: 500; }
@media (hover: hover) { tr.turn-group-row:hover { background: var(--surface-2); } }
@media (min-width: 761px) { tr.turn-child-row td:first-child { padding-left: 18px; color: var(--muted); } }
table .chip.err { white-space: normal; height: auto; padding: 2px 8px; line-height: 1.4; max-width: 24em; text-align: left; }
.td-stack { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.nowrap { white-space: nowrap; }
.id-cell { display: inline-flex; align-items: center; gap: var(--sp-1); }
.id-cell .mono, .nowrap { white-space: nowrap; }
.clip { display: inline-block; max-width: 14em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }

/* toolbar & fleet summary */
.toolbar { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.toolbar-note { font-size: var(--fs-xs); font-variant-numeric: tabular-nums; margin-left: auto; }
.search { position: relative; display: flex; align-items: center; }
.search i { position: absolute; left: 9px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 30px; width: 220px; }
.search-sm input { height: 28px; width: 184px; font-size: var(--fs-xs); }
.fleet-bar {
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-3);
  padding: var(--sp-2) var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  font-size: var(--fs-xs); color: var(--fg-2); font-variant-numeric: tabular-nums;
}
.fleet-stat { display: inline-flex; align-items: center; gap: 6px; }

/* account cards & 10+ fleet compact mode */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: var(--sp-3); }
.cards.compact { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--sp-2); }
.card {
  min-width: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface);
  padding: 13px 15px 12px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow-card);
  transition: border-color .15s var(--ease), background-color .15s var(--ease), box-shadow .15s var(--ease);
}
.cards.compact .card { padding: 9px 12px; gap: 6px; }
.cards.compact .asides { display: none; }
.cards.compact .meter-row { grid-template-columns: auto minmax(0, 1fr); }
.cards.compact .meter-row .m-name { flex: none; white-space: nowrap; }
.cards.compact .meter-row .m-val { text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cards.compact .card-foot { flex-wrap: wrap; gap: 4px 8px; }
@media (hover: hover) { .card:hover { border-color: var(--border-strong); } }
.card.active-card { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.card.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 35%, var(--surface)); }
.card-h { display: flex; align-items: flex-start; gap: 10px; }
.card-h input[type=checkbox] { margin-top: 3px; width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.card-who { min-width: 0; flex: 1; }
.card-name { font-weight: 600; font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 5px; }
.limit-pills { display: flex; gap: var(--sp-1); flex-wrap: wrap; }
.meter-row, .stat-bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 10px; font-size: var(--fs-xs); }
.meter-row .m-name { color: var(--fg-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-bar-row .m-name { color: var(--fg-2); overflow-wrap: anywhere; min-width: 0; }
.meter-row .m-val, .stat-bar-row .m-val { color: var(--muted); font-variant-numeric: tabular-nums; }
.meter-row progress, .stat-bar-row progress { grid-column: 1 / -1; width: 100%; height: 4px; appearance: none; -webkit-appearance: none; border: 0; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--surface-2); border-radius: 2px; }
progress::-webkit-progress-value { background: var(--ok-dot); border-radius: 2px; transition: width .2s var(--ease); }
progress::-moz-progress-bar { background: var(--ok-dot); }
progress.near::-webkit-progress-value { background: var(--warn-dot); }
progress.near::-moz-progress-bar { background: var(--warn-dot); }
progress.full::-webkit-progress-value { background: var(--err-dot); }
progress.full::-moz-progress-bar { background: var(--err-dot); }
progress.accent-bar::-webkit-progress-value { background: var(--accent); }
progress.accent-bar::-moz-progress-bar { background: var(--accent); }
.asides { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 3px 12px; margin: 0; font-size: var(--fs-xs); }
.asides dt { color: var(--muted); }
.asides dd { margin: 0; color: var(--fg-2); font-variant-numeric: tabular-nums; }
.card-foot { display: flex; align-items: center; gap: var(--sp-2); margin-top: auto; padding-top: var(--sp-2); border-top: 1px solid var(--border); font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.card-foot .card-acts { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; flex: none; }
.card-foot .card-acts .icon-btn.sm { width: 30px; height: 30px; }
.card-err {
  font-size: var(--fs-xs); color: var(--err); padding: 6px 9px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--err-dot) 6%, var(--surface)); border: 1px solid color-mix(in srgb, var(--err-dot) 25%, var(--border));
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); flex-wrap: wrap;
}
.card-check-note {
  font-size: var(--fs-xs); padding: 6px 9px; border-radius: var(--radius);
  background: var(--bg); border: 1px solid var(--border); color: var(--fg-2);
}

/* persistent usage stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--sp-3); margin-top: var(--sp-2); }
.stats-col { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); display: flex; flex-direction: column; gap: var(--sp-2); }
.stats-col-title { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }

/* settings */
.lead { font-size: var(--fs-sm); color: var(--fg-2); margin: 0 0 var(--sp-3); }
.lead:empty { display: none; }
.group { margin-bottom: var(--sp-4); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.group-h { padding: 10px 16px; font-size: var(--fs-sm); font-weight: 600; border-bottom: 1px solid var(--border); }
.setting { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding: 12px 16px; border-top: 1px solid var(--border); }
.group-h + .setting { border-top: 0; }
/* inside the settings tabs the tab already names the group */
#settingsBox .group-h { display: none; }
.setting-text { min-width: 0; }
.setting-label { font-size: var(--fs-sm); font-weight: 500; display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.setting-desc { font-size: var(--fs-xs); color: var(--muted); margin-top: 2px; max-width: 64ch; text-wrap: pretty; }
.setting select, .setting input[type=text] { min-width: 170px; }
.setting.saving { opacity: .6; }
.about { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--sp-2) 20px; margin: 0; padding: 12px 16px; font-size: var(--fs-sm); }
.about dt { color: var(--muted); }
.about dd { margin: 0; word-break: break-all; font-variant-numeric: tabular-nums; }

.subtabs { display: flex; flex-wrap: wrap; gap: 3px; margin: 0 0 var(--sp-3); padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); width: fit-content; max-width: 100%; }
.subtabs::-webkit-scrollbar { display: none; }
.subtab { height: 28px; padding: 0 9px; border: 0; background: transparent; color: var(--muted); font-size: var(--fs-xs); font-weight: 500; }
@media (hover: hover) { .subtab:hover { background: var(--surface-2); color: var(--fg); border: 0; } }
.subtab[aria-selected="true"] { background: var(--surface-2); color: var(--fg); font-weight: 600; box-shadow: inset 0 0 0 1px var(--border); }
.subtab:active { transform: none; }
@media (max-width: 760px) { .subtabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; mask-image: linear-gradient(to right, #000 92%, transparent); } }

/* slim */
.presets { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 10px; }
.preset { display: flex; flex-direction: column; justify-content: flex-start; align-items: flex-start; gap: 4px; height: auto; padding: 12px 14px; text-align: left; border-radius: var(--radius-lg); font-weight: 400; white-space: normal; }
.preset:active { transform: none; }
.preset[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.preset-name { font-weight: 600; font-size: var(--fs-sm); display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.preset-desc { font-size: var(--fs-xs); color: var(--muted); }

/* diag */
.kv-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3); }
@media (max-width: 960px) { .onboard-steps { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .kv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); } }
.kv { padding: 11px 14px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); min-width: 0; }
.kv-k { font-size: var(--fs-xs); color: var(--muted); font-weight: 500; }
.kv-v { font-size: var(--fs-sm); margin-top: 3px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
details.raw { margin-top: var(--sp-3); }
details.raw summary, details.how summary, details.fold > summary { cursor: pointer; color: var(--muted); font-size: var(--fs-xs); user-select: none; }
details.raw pre { max-height: 360px; overflow: auto; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }

/* stt */
.drop {
  display: flex; align-items: center; gap: 14px; padding: 22px 18px; margin-bottom: var(--sp-3); border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg); background: var(--surface); cursor: pointer; transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.drop i { width: 20px; height: 20px; color: var(--muted); }
.drop i svg { width: 20px; height: 20px; }
.drop:hover, .drop.drag { border-color: var(--accent); background: var(--accent-soft); }
.drop-title { font-weight: 500; }
.drop-sub { font-size: var(--fs-xs); margin-top: 2px; }
pre.out { margin: 0; min-height: 76px; max-height: 50vh; overflow: auto; white-space: pre-wrap; font-family: var(--font); font-size: var(--fs-base); line-height: 1.6; color: var(--fg); }
pre.out:empty::before { content: "（还没有转写）"; color: var(--muted); }
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { padding: var(--sp-2) 0; border-top: 1px solid var(--border); font-size: var(--fs-sm); display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); flex-wrap: wrap; }
.hist li:first-child { border-top: 0; padding-top: 0; }
.hist .when { font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; width: 100%; }

/* toast & dialogs */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 50; transform: translateX(-50%); display: flex; align-items: center; gap: var(--sp-2);
  padding: 9px 14px; border-radius: var(--radius-lg); background: var(--toast-bg); color: var(--toast-text); font-size: var(--fs-sm);
  box-shadow: var(--shadow-sm); max-width: min(92vw, 560px);
}
.toast[data-kind="err"] { border-left: 3px solid var(--err-dot); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }
dialog {
  width: min(520px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--fg); box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(0, 0, 0, .32); }
dialog form { padding: 18px 20px; display: flex; flex-direction: column; gap: var(--sp-2); }
dialog h2 { margin: 0 0 2px; font-size: var(--fs-md); font-weight: 600; }
dialog p { margin: 0; font-size: var(--fs-sm); }
dialog label { margin-top: 6px; }
dialog input[type=text] { width: 100%; }
details.how { margin-top: var(--sp-1); font-size: var(--fs-xs); }
details.how ol { margin: var(--sp-2) 0; padding-left: 18px; color: var(--fg-2); }
details.how li { margin: var(--sp-1) 0; }
pre.snippet { max-height: 88px; overflow: auto; padding: var(--sp-2) 10px; margin: 0 0 6px; white-space: pre-wrap; word-break: break-all; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); font-size: var(--fs-xs); }
.dlg-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); margin-top: 10px; }

/* wide screens: keep content readable, never leave a giant empty column */
@media (min-width: 1500px) { .view, .notices { max-width: 1280px; } }

/* tablets: tiles 2 × 2 */
@media (max-width: 1080px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* phones (390px): sidebar becomes strip + wide tables transform into responsive card layout */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side {
    position: sticky; top: 0; z-index: 6; height: auto; flex-direction: row; align-items: center; gap: 0; padding: 0 var(--sp-2);
    padding-top: env(safe-area-inset-top); border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none;
    mask-image: linear-gradient(to right, #000 92%, transparent);
  }
  .side::-webkit-scrollbar { display: none; }
  .brand, .side-foot, .nav-sep { display: none; }
  nav { flex-direction: row; gap: 4px; padding: 6px 0; }
  nav a { height: 34px; padding: 0 10px; white-space: nowrap; font-size: var(--fs-sm); }
  nav a[aria-current="page"]::before { display: none; }
  nav a i[data-icon] { width: 15px; height: 15px; }
  .hide-sm { display: none; }
  main { padding: 0 14px calc(32px + env(safe-area-inset-bottom)); }
  .bar { position: static; height: 52px; margin: 0 -14px 8px; padding: 0 14px; backdrop-filter: none; gap: 8px; }
  .bar-actions { gap: 4px; }
  .pill { padding: 0 8px; font-size: 11px; }
  .verdict { flex-direction: column; align-items: stretch; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
  .tile-v { font-size: var(--fs-md); }
  .cards, .cards.compact { grid-template-columns: minmax(0, 1fr); }
  .setting { flex-wrap: wrap; }
  .setting.has-field select, .setting.has-field input { width: 100%; }
  .search input, .search-sm input { width: 100%; font-size: 16px; }
  .search-sm input { height: 34px; }
  .search { flex: 1 1 180px; min-width: 160px; }
  .filter-pills { width: 100%; }
  .toolbar-note { margin-left: 0; width: 100%; }
  button, input[type=text], input[type=password], input[type=search], input[type=number], select { height: 40px; }
  .filter-pill, button.ghost-sm, .select-sm { height: 34px; }
  input, textarea, select { font-size: 16px; }
  .icon-btn { width: 38px; }
  .switch { height: 24px; width: 40px; }
  .switch::after { width: 18px; height: 18px; }
  .switch[aria-checked="true"]::after { transform: translateX(16px); }
  .icon-btn.sm { width: 32px; height: 32px; }
  dialog, dialog.dlg-wide { width: 100%; max-width: 100%; max-height: 90dvh; margin: auto 0 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .about { grid-template-columns: 1fr; gap: 2px 0; }
  .about dd { margin-bottom: var(--sp-2); }
  /* Responsive mobile card-table layout */
  table.resp-cards thead { display: none; }
  table.resp-cards tbody { display: flex; flex-direction: column; gap: var(--sp-2); }
  table.resp-cards tr {
    display: flex; flex-direction: column; gap: var(--sp-1); padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg);
  }
  table.resp-cards td {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--sp-2);
    padding: 2px 0; border-bottom: 0; text-align: right;
  }
  table.resp-cards td[data-label]::before {
    content: attr(data-label); color: var(--muted); font-size: var(--fs-xs); font-weight: 500; text-align: left; flex: 0 0 auto;
  }
  table.resp-cards tr.turn-child-row { border-left: 3px solid var(--accent); }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton, .view, .rec-ring { animation: none !important; }
  button:not(:disabled):active { transform: none; }
}
.card-sub { font-size: var(--fs-xs); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.fold { margin-top: var(--sp-3); padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
details.fold > summary { font-size: var(--fs-sm); font-weight: 600; color: var(--fg); }
details.fold[open] > summary { margin-bottom: var(--sp-2); }

.notice-actions { margin-left: auto; display: inline-flex; align-items: center; gap: var(--sp-1); flex: none; }
.notice-close {
  width: 32px; height: 32px; padding: 0; border-color: transparent; background: transparent;
  color: var(--muted); font-size: var(--fs-base); line-height: 1; border-radius: var(--radius-sm);
}
@media (hover: hover) { .notice-close:hover { background: var(--surface-2); color: var(--fg); } }
.empty-state {
  display: flex; align-items: center; gap: var(--sp-2); color: var(--muted); font-size: var(--fs-sm); margin: 10px 0;
}
.empty-state i { color: var(--muted); }
td, .card-name, .card-sub, .m-name, .client-kv-val { overflow-wrap: anywhere; }

/* v0.3.26: readiness steps, insights banner/cards, dark-theme chart contrast, and group delete pill */
.readiness-panel { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.readiness-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); flex-wrap: wrap; width: 100%; }
.readiness-steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-2); width: 100%; }
.readiness-step {
  display: flex; align-items: flex-start; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); font-size: var(--fs-xs);
}
.readiness-step.ok { border-color: color-mix(in srgb, var(--ok) 35%, var(--border)); }
.readiness-step.pending { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); background: color-mix(in srgb, var(--warn) 5%, var(--bg)); }
.step-dot { font-weight: 700; color: var(--muted); line-height: 1.4; }
.readiness-step.ok .step-dot { color: var(--ok); }
.readiness-step.pending .step-dot { color: var(--warn); }
.step-title { font-weight: 600; color: var(--fg); }
.step-detail { color: var(--muted); margin-top: 2px; line-height: 1.35; }
.step-act { margin-top: 4px; }
.insights-banner { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); flex-wrap: wrap; border-left: 3px solid var(--accent); }
.insights-box {
  display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-3); margin-bottom: var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); font-size: var(--fs-sm);
}
.insights-metrics { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; font-size: var(--fs-xs); color: var(--fg-2); font-variant-numeric: tabular-nums; }
.insights-recs { display: flex; flex-direction: column; gap: var(--sp-1); margin: 0; padding-left: 18px; font-size: var(--fs-xs); color: var(--fg-2); }
@media (max-width: 960px) { .readiness-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .readiness-steps { grid-template-columns: minmax(0, 1fr); } }

/* v0.3.31: Voicenotes Studio-grade Capture Deck, Floating Elevated Result Cards, Popover Menu & Responsive Polish */
.nav-sep { margin: 12px 10px 4px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 11px; font-weight: 600; color: var(--muted); }
.nav-badge { margin-left: auto; padding: 0 6px; height: 18px; line-height: 18px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); font-size: 11px; font-variant-numeric: tabular-nums; color: var(--fg-2); }
.palette-btn kbd { margin-left: 4px; }
.small { font-size: var(--fs-xs); }
.spacer { flex: 1; }
.input-sm { width: 110px; }

/* Segmented tabs */
.seg { display: inline-flex; padding: 3px; border: 1px solid color-mix(in srgb, var(--border) 70%, transparent); border-radius: var(--radius); background: var(--surface-2); gap: 2px; }
.seg-btn {
  height: 30px; padding: 0 12px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--fg-2);
  font-size: var(--fs-sm); font-weight: 500; transition: background-color .15s var(--ease), color .15s var(--ease);
}
@media (hover: hover) { .seg-btn:hover { background: transparent; color: var(--fg); border: 0; } }
.seg-btn.is-active { background: var(--surface); color: var(--fg); font-weight: 600; box-shadow: var(--shadow-1), 0 0 0 1px var(--border); }
.seg-btn:active { transform: none !important; }

/* Capture deck (single elevated card, recessed mic bay) */
.capture-deck {
  padding: 14px 16px 16px; border: 1px solid var(--border); border-radius: var(--radius-xl);
  background: var(--surface); box-shadow: var(--shadow-1);
}
.capture-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-bottom: var(--sp-3); flex-wrap: wrap; }
.mic-deck {
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center; gap: 18px;
  padding: 14px 16px; border: 1px solid color-mix(in srgb, var(--border) 75%, transparent); border-radius: 10px; background: var(--surface-2);
}
.rec-btn {
  position: relative; width: 56px; height: 56px; padding: 0; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--accent-fg); flex: none;
  box-shadow: 0 1px 2px rgb(0 0 0 / .15), 0 6px 16px -6px color-mix(in srgb, var(--accent) 65%, transparent);
}
@media (hover: hover) { .rec-btn:not(:disabled):hover { background: var(--accent-hover); border: 0; } }
.rec-btn[aria-pressed="true"] {
  background: var(--rec); color: var(--fg-on-status);
  box-shadow: 0 1px 2px rgb(0 0 0 / .15), 0 6px 18px -6px color-mix(in srgb, var(--rec) 75%, transparent);
}
.rec-btn[aria-pressed="true"]:hover { background: var(--rec); }
.rec-ring { position: absolute; inset: -5px; border-radius: 50%; border: 2px solid var(--rec); opacity: 0; pointer-events: none; }
@media (prefers-reduced-motion: no-preference) {
  .rec-btn[aria-pressed="true"] .rec-ring { animation: rec-pulse 1.6s var(--ease) infinite; }
}
@keyframes rec-pulse {
  0% { transform: scale(.95); opacity: .52; }
  70% { transform: scale(1.22); opacity: 0; }
  100% { transform: scale(1.25); opacity: 0; }
}
.rec-icon-stack { display: inline-flex; align-items: center; justify-content: center; }
.rec-btn .mic-idle svg, .rec-btn .mic-idle { width: 22px; height: 22px; }
.rec-btn .mic-live-stop { display: none; width: 15px; height: 15px; border-radius: 3px; background: currentColor; }
.rec-btn[aria-pressed="true"] .mic-idle { display: none; }
.rec-btn[aria-pressed="true"] .mic-live-stop { display: block; }
.rec-readout { min-width: 126px; }
.rec-time-row { display: flex; align-items: center; gap: 8px; }
.rec-time { font-family: var(--font); font-size: var(--fs-time); font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: .01em; color: var(--fg); }
.rec-time.is-live { color: var(--rec); }
.rec-hint { margin-top: 4px; }
.wave-well { min-width: 0; height: 52px; display: flex; align-items: center; }
.rec-wave { width: 100%; height: 52px; display: block; }
.rec-controls { display: inline-flex; align-items: center; gap: var(--sp-2); flex: none; }
.live-toggle {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--fg); font-size: var(--fs-sm); font-weight: 500;
}
.live-toggle .live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.live-toggle[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.live-toggle[aria-pressed="true"] .live-dot { background: var(--accent); }

.live-area { margin-top: var(--sp-3); padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--border)); border-radius: 10px; background: var(--surface-2); }
.live-head { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-2); }
.live-state { font-size: var(--fs-xs); font-weight: 600; color: var(--accent); }
.live-chunks { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.live-chunk-pill { font-size: var(--fs-xs); padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--fg-2); font-variant-numeric: tabular-nums; }
.live-chunk-pill[data-status="done"] { color: var(--ok); border-color: color-mix(in srgb, var(--ok-dot) 30%, var(--border)); }
.live-chunk-pill[data-status="error"] { color: var(--err); border-color: color-mix(in srgb, var(--err-dot) 30%, var(--border)); }
.live-text { margin: 0; white-space: pre-wrap; font-family: var(--font); font-size: var(--fs-md); line-height: 1.7; max-height: 220px; overflow: auto; }

/* Transcription Results Section (no outer box wrapper — cards float directly on canvas) */
.tx-section { margin-top: var(--sp-5); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-bottom: var(--sp-3); flex-wrap: wrap; }
.section-title { margin: 0; font-size: var(--fs-md); font-weight: 650; color: var(--fg); line-height: 1.25; text-wrap: balance; }
.section-tools { flex-wrap: wrap; }
.tx-cards { display: flex; flex-direction: column; gap: var(--sp-2); }
.tx-card {
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); padding: 16px 18px 12px;
  box-shadow: var(--shadow-card); display: flex; flex-direction: column; gap: 10px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.tx-card.is-checked { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent), var(--shadow-1); }
.tx-card-top { display: flex; align-items: flex-start; gap: 10px; }
.tx-card-top input[type="checkbox"] { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.tx-card-head { flex: 1; min-width: 0; }
.tx-card-title { font-size: var(--fs-md); font-weight: 600; color: var(--fg); line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 4px; font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.tx-card-main { display: flex; flex-direction: column; gap: 10px; }
@media (min-width: 1160px) {
  .tx-card-main.has-atts { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 360px); gap: 16px; align-items: start; }
}
.tx-card-body { margin: 0; max-width: 74ch; white-space: pre-wrap; font-family: var(--font); font-size: var(--fs-base); line-height: 1.72; color: var(--fg); overflow-wrap: anywhere; text-wrap: pretty; }
.tx-card-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding-top: 8px; border-top: 1px solid color-mix(in srgb, var(--border) 65%, transparent); }
.card-more-wrap { position: relative; margin-left: auto; }
.card-more-menu {
  position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 25; min-width: 152px; padding: 4px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 2px;
}
.card-more-row {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 32px; padding: 0 10px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--fg); font-size: var(--fs-sm); justify-content: flex-start;
}
@media (hover: hover) { .card-more-row:hover { background: var(--surface-2); border: 0; } }
.card-more-row.is-danger { color: var(--err); }
@media (hover: hover) { .card-more-row.is-danger:hover { background: color-mix(in srgb, var(--err-dot) 10%, var(--surface)); } }
.tx-attachments { display: flex; flex-direction: column; gap: 6px; }
.tx-att { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); padding: 8px 12px; }
.tx-att summary { cursor: pointer; font-size: var(--fs-xs); font-weight: 600; color: var(--fg-2); user-select: none; }
.tx-att-body { margin-top: 8px; font-size: var(--fs-sm); line-height: 1.65; color: var(--fg); }
.tx-att-body p { margin: 0 0 6px; }
.tx-att-body ul { margin: 4px 0; padding-left: 18px; }
.tx-att-body ul.md-todos { list-style: none; padding-left: 0; }
.tx-att-body .md-todo label { display: flex; align-items: flex-start; gap: 7px; font-weight: 400; color: var(--fg); cursor: pointer; padding: 2px 0; }
.tx-att-body .md-todo input[type="checkbox"] { margin-top: 3px; accent-color: var(--accent); }
.batch-bar {
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-3);
  padding: 8px 12px; border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border)); border-radius: var(--radius); background: var(--accent-soft);
}
.empty-well {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 36px 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 70%, transparent); text-align: center; color: var(--muted);
}
.empty-well i { width: 22px; height: 22px; opacity: .75; }
.empty-well i svg { width: 22px; height: 22px; }
.empty-well-title { font-size: var(--fs-sm); font-weight: 600; color: var(--fg-2); }
.empty-well-desc { font-size: var(--fs-xs); color: var(--muted); max-width: 44ch; line-height: 1.5; }
@media (prefers-reduced-motion: no-preference) {
  .drawer:not([hidden]) { animation: drawer-in .18s var(--ease); }
  dialog[open] { animation: dlg-in .15s var(--ease); }
}
@keyframes drawer-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }
@keyframes dlg-in { from { opacity: 0; transform: scale(.98); } to { opacity: 1; transform: scale(1); } }

/* Slide-over Memories & Todos Drawer */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(20, 24, 22, .34); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 45; width: min(460px, 100vw);
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overscroll-behavior: contain;
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.drawer-title { margin: 0; font-size: var(--fs-md); font-weight: 600; }
.drawer-tabs { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: 10px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.drawer-tabs .search-sm { flex: 1 1 190px; min-width: 0; }
.drawer-tabs .search-sm input { width: 100%; }
.drawer-body { flex: 1; overflow-y: auto; padding: 12px 16px; overscroll-behavior: contain; }
.mem-item {
  display: flex; align-items: center; gap: 10px; padding: 4px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); margin-bottom: var(--sp-2); transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
@media (hover: hover) { .mem-item:hover { border-color: var(--border-strong); background: var(--surface); } }
.mem-item input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; flex: none; }
.mem-item-btn {
  flex: 1; min-width: 0; height: auto; padding: 6px 2px; border: 0; background: transparent;
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; font-weight: 400;
}
@media (hover: hover) { .mem-item-btn:hover { background: transparent; border: 0; } }
.mem-item-title { width: 100%; font-size: var(--fs-sm); font-weight: 600; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mem-item-meta { font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.todo-row { display: flex; align-items: flex-start; gap: 8px; padding: 9px 10px; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.todo-label { flex: 1; min-width: 0; align-items: flex-start; overflow-wrap: anywhere; }
.todo-label input { margin-top: 3px; flex: none; width: 16px; height: 16px; }
.todo-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
@media (hover: hover) { .del-btn:not(:disabled):hover { color: var(--err); background: color-mix(in srgb, var(--err-dot) 10%, var(--surface)); } }
#memoriesDrawer .batch-bar { margin: 0; border-radius: 0; border-width: 1px 0 0; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }

/* Dialogs & Modals */
dialog.dlg-wide { width: min(720px, calc(100vw - 32px)); }
dialog { overscroll-behavior: contain; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: 14px 18px; border-bottom: 1px solid var(--border); }
.dlg-head h2 { margin: 0; font-size: var(--fs-md); font-weight: 600; }
.dlg-body { padding: 14px 18px 18px; display: flex; flex-direction: column; gap: var(--sp-3); max-height: 78vh; overflow-y: auto; overscroll-behavior: contain; }
#aiSecRun, #aiSecAsk { display: flex; flex-direction: column; gap: var(--sp-3); }
#dlgConfirmText { white-space: pre-wrap; line-height: 1.55; }
.ai-out { max-height: 280px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.diff-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
.diff-col { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); overflow: hidden; }
.diff-col-h { padding: 6px 10px; font-size: var(--fs-xs); font-weight: 600; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.diff-lines { max-height: 320px; overflow: auto; padding: 8px 10px; font-size: var(--fs-sm); line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.diff-line.is-changed-before { background: color-mix(in srgb, var(--err-dot) 10%, transparent); border-left: 2px solid var(--err-dot); padding-left: 6px; }
.diff-line.is-changed-after { background: color-mix(in srgb, var(--ok-dot) 12%, transparent); border-left: 2px solid var(--ok-dot); padding-left: 6px; }
.mem-detail-body { white-space: pre-wrap; max-width: 68ch; font-size: var(--fs-sm); line-height: 1.65; max-height: 50vh; overflow-y: auto; }
#memNoteInput { flex: 1; min-width: 0; }
.dlg-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--sp-2); }
.dlg-actions button { height: 32px; padding: 0 12px; font-size: var(--fs-sm); }
#dlgPalette { margin: 8vh auto auto; }
.palette-search { display: flex; align-items: center; gap: var(--sp-2); padding: 12px 14px; border-bottom: 1px solid var(--border); }
.palette-search input { flex: 1; border: 0; background: transparent; padding: 0; font-size: var(--fs-base); box-shadow: none; }
.palette-list { max-height: 340px; overflow-y: auto; padding: 6px; overscroll-behavior: contain; }
.palette-item {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); height: 34px; padding: 0 10px;
  border: 0; background: transparent; font-weight: 400; text-align: left;
}
.palette-item > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
@media (hover: hover) { .palette-item:hover { background: var(--surface-2); } }
.wb-list-pad { padding: 0 16px 12px; display: flex; flex-direction: column; gap: 6px; }
.wb-item-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); font-size: var(--fs-sm); flex-wrap: wrap; }
.wb-editor-box { margin: 0 16px 14px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); display: flex; flex-direction: column; gap: var(--sp-2); }
.dlg-body > .wb-list-pad { padding: 0; }
.dlg-body > .wb-editor-box { margin: 0; }
.wb-editor-head { font-size: var(--fs-xs); font-weight: 600; color: var(--fg-2); }
.wb-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
.wb-check-group { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.export-opt { width: 100%; justify-content: space-between; height: 38px; padding: 0 12px; margin-bottom: 0; }
.date-group { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.date-head {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border: 0; background: transparent;
  color: var(--fg-2); font-size: var(--fs-xs); font-weight: 600; cursor: pointer; align-self: flex-start; border-radius: var(--radius-sm);
}
.date-chevron { width: 14px; height: 14px; transition: transform .15s var(--ease); }
.date-head[aria-expanded="false"] .date-chevron { transform: rotate(-90deg); }
@media (hover: hover) { .date-head:hover { background: var(--surface-2); color: var(--fg); } }
.date-body { display: flex; flex-direction: column; gap: var(--sp-2); }
.wb-audio { width: 100%; height: 34px; border-radius: var(--radius); }
.wb-statusbar { display: flex; align-items: center; gap: 8px; padding: 12px 2px 16px; }
.todo-add-row { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.todo-add-row input { flex: 1; }
.toast-action {
  padding: 2px 8px; border-radius: var(--radius-sm); border: 1px solid var(--toast-action-border);
  background: var(--toast-action-bg); color: inherit; font-size: var(--fs-xs); height: 24px;
}
.toast-close { border: 0; background: transparent; color: inherit; opacity: .75; padding: 0 4px; height: 24px; }
.tx-edit-box { display: flex; flex-direction: column; gap: var(--sp-2); }
@media (forced-colors: active) {
  .rec-btn, .switch, .card, .tx-card, .capture-deck, dialog, .palette-item[aria-selected="true"] { forced-color-adjust: auto; border: 1px solid CanvasText; }
  :focus-visible { outline: 2px solid Highlight; }
}
@media (max-width: 760px) {
  .bar h1 { font-size: 16px; }
  .bar-actions { gap: 3px; }
  .pill { max-width: 144px; overflow: hidden; text-overflow: ellipsis; }
  .mic-deck { grid-template-columns: auto 1fr; }
  .rec-btn { width: 56px; height: 56px; }
  .wave-well { grid-column: 1 / -1; }
  .rec-controls { grid-column: 1 / -1; justify-content: flex-start; }
  .diff-grid, .wb-grid-2 { grid-template-columns: 1fr; }
  #dlgPalette { width: calc(100vw - 24px); max-width: calc(100vw - 24px); margin: 4vh auto auto; border-radius: var(--radius-lg); }
  .palette-search input { font-size: 16px; }
  .dlg-actions button { height: 40px; min-width: 72px; }
  .wb-statusbar { padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  .drawer-head, .drawer-body { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}
