/* ==========================================================================
   爆剧获取 · drama-portal — style.css
   System: 通告单与改稿色页. Tokens, rules and reasons live in /DESIGN.md;
   who it is for lives in /PRODUCT.md. One light theme for both hosts.
   Sections: 1 tokens · 2 base · 3 shell · 4 layout · 5 components · 6 pages
   7 workbench forms · 8 workbench shell + conversation · 9 responsive
   10 motion · 11 skills dialog · 12 image previews · 13 run outcome · 14 batch progress
   ========================================================================== */

/* 1 · tokens ------------------------------------------------------------- */
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("/static/fonts/atkinson-hyperlegible-next-latin-wght-normal.woff2") format("woff2");
  /* Latin and digits only. Dashes, ellipsis and the middle dot stay with the CJK face. */
  unicode-range: U+0020-007E, U+00A0-00B6, U+00B8-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC,
    U+2010-2013, U+2018-201F, U+2022, U+2030, U+2032-2033, U+2039-203A, U+20AC, U+2122, U+2212, U+2215;
}
@font-face {
  font-family: "Atkinson Hyperlegible Mono";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("/static/fonts/atkinson-hyperlegible-mono-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0020-007E, U+00A0-00B6, U+00B8-00FF, U+2010-2013, U+2018-201F, U+2022, U+2212, U+2215;
}
:root {
  color-scheme: light;

  /* 纸与案 — surfaces */
  --bg: #f1f2f4;            /* 案: the desk behind the sheets */
  --bg-deep: #e8eaed;       /* wells: tracks, gutters, empty covers */
  --surface: #ffffff;       /* 纸: sheets, panels, table bodies */
  --surface-2: #f7f8f9;     /* a quiet band on a sheet */
  --surface-3: #eceef1;     /* fills: hover, neutral slips */
  --field: #ffffff;
  --code-bg: #f4f5f7;
  --row-hover: #f6f7f9;

  /* rules */
  --line: #dfe2e6;
  --line-strong: #b9bec7;
  --field-line: #8b919d;
  --field-line-hover: #565c68;

  /* 墨 — text */
  --text: #15171c;
  --text-2: #33373f;
  --muted: #565c68;
  --faint: #626874;
  --placeholder: #6f7581;

  /* 色页 — revision pages: paper tint / rule / ink. The only chroma in the system. */
  --page-blue: #e3edfb;      --rule-blue: #a9c3ee;      --ink-blue: #1c4fb0;
  --page-pink: #fbe3ec;      --rule-pink: #eeacc4;      --ink-pink: #a32257;
  --page-yellow: #fbf0bf;    --rule-yellow: #dcc355;    --ink-yellow: #6b5000;
  --page-green: #dff1e0;     --rule-green: #9fd0a4;     --ink-green: #1e6a2c;
  --page-goldenrod: #f2cd5d; --rule-goldenrod: #c49a13; --ink-goldenrod: #3d2e00;
  --page-salmon: #fbe0d4;    --rule-salmon: #edb098;    --ink-salmon: #96391a;
  --page-cherry: #f9dcdc;    --rule-cherry: #e8a3a3;    --ink-cherry: #a41d24;
  --page-buff: #f1e6d0;      --rule-buff: #d6c08f;      --ink-buff: #5f4a1c;
  --page-gray: #e9ebee;      --rule-gray: #c2c7cf;      --ink-gray: #474c57;

  /* roles — every role resolves to ink or to one page */
  --accent: var(--text);
  --accent-hover: #33373f;
  --on-accent: #ffffff;
  --accent-text: var(--text);
  --accent-soft: var(--surface-3);
  --accent-line: var(--line-strong);
  --link: var(--ink-blue);
  --btn2-bg: #ffffff;
  --btn2-bg-hover: var(--surface-3);
  --info: var(--ink-blue);
  --info-text: var(--ink-blue);
  --info-soft: var(--page-blue);
  --info-line: var(--rule-blue);
  --ok: var(--ink-green);
  --ok-text: var(--ink-green);
  --ok-soft: var(--page-green);
  --ok-line: var(--rule-green);
  --warn: var(--ink-yellow);
  --warn-text: var(--ink-yellow);
  --warn-soft: var(--page-yellow);
  --warn-line: var(--rule-yellow);
  --err: var(--ink-cherry);
  --err-text: var(--ink-cherry);
  --err-soft: var(--page-cherry);
  --err-line: var(--rule-cherry);
  --on-err: #ffffff;
  --alarm: var(--ink-pink);
  --alarm-text: var(--ink-pink);
  --alarm-strong: #7d1641;
  --alarm-soft: var(--page-pink);
  --alarm-soft-2: #f8d3e0;
  --ring: var(--ink-blue);
  --focus-halo: rgba(28, 79, 176, 0.2);
  --header-bg: #ffffff;
  --header-text: var(--text-2);
  --header-line: var(--text);
  --scrim: rgba(21, 23, 28, 0.45);

  /* elevation — sheets lie flat; only things that float cast a shadow */
  --shadow-md: 0 2px 8px rgba(21, 23, 28, 0.1);
  --shadow-lg: 0 8px 24px rgba(21, 23, 28, 0.14);
  --shadow-xl: 0 16px 48px rgba(21, 23, 28, 0.2);

  /* type — Latin and digits from Atkinson Hyperlegible, Chinese from the system */
  --font-body: "Atkinson Hyperlegible Next", -apple-system, BlinkMacSystemFont, "PingFang SC",
    "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans SC",
    "Noto Sans CJK SC", "Source Han Sans SC", "Segoe UI", sans-serif;
  --font-heading: var(--font-body);
  --font-mono: "Atkinson Hyperlegible Mono", ui-monospace, "SF Mono", "Cascadia Mono", Consolas, Menlo,
    "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", monospace;
  --text-xs: 0.75rem;     /* 12 — the floor */
  --text-sm: 0.8125rem;   /* 13 — tables, meta */
  --text-base: 0.875rem;  /* 14 — interface */
  --text-md: 0.9375rem;   /* 15 — reading: conversation, script lines */
  --text-lg: 1rem;        /* 16 — section titles */
  --text-xl: 1.25rem;     /* 20 — page titles */
  --text-2xl: 1.75rem;    /* 28 — the one large line on a page */

  /* space */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-12: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* shape — paper corners */
  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 6px;
  --radius-xl: 8px;
  --radius-full: 999px;

  /* alias kept for the batch-progress rules */
  --border: var(--line);

  /* motion — state changes only */
  --dur-fast: 120ms;
  --dur: 160ms;
  --dur-slow: 220ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);

  /* layout */
  --container: 1280px;
  --gutter: 24px;
  --top-h: 48px;
  --control-h: 32px;
  --z-header: 20;
}
/* The admin host is the goldenrod page: same system, one band that says whose data you are touching. */
body.admin-host {
  --header-bg: var(--page-goldenrod);
  --header-text: var(--ink-goldenrod);
}
/* 色页 hook: data-page="blue|pink|yellow|green|goldenrod|salmon|cherry|buff|gray" sets --p / --p-rule / --p-ink. */
[data-page] { --p: var(--page-gray); --p-rule: var(--rule-gray); --p-ink: var(--ink-gray); }
[data-page="blue"] { --p: var(--page-blue); --p-rule: var(--rule-blue); --p-ink: var(--ink-blue); }
[data-page="pink"] { --p: var(--page-pink); --p-rule: var(--rule-pink); --p-ink: var(--ink-pink); }
[data-page="yellow"] { --p: var(--page-yellow); --p-rule: var(--rule-yellow); --p-ink: var(--ink-yellow); }
[data-page="green"] { --p: var(--page-green); --p-rule: var(--rule-green); --p-ink: var(--ink-green); }
[data-page="goldenrod"] { --p: var(--page-goldenrod); --p-rule: var(--rule-goldenrod); --p-ink: var(--ink-goldenrod); }
[data-page="salmon"] { --p: var(--page-salmon); --p-rule: var(--rule-salmon); --p-ink: var(--ink-salmon); }
[data-page="cherry"] { --p: var(--page-cherry); --p-rule: var(--rule-cherry); --p-ink: var(--ink-cherry); }
[data-page="buff"] { --p: var(--page-buff); --p-rule: var(--rule-buff); --p-ink: var(--ink-buff); }

/* 2 · base --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--top-h) + 16px); scrollbar-color: var(--line-strong) transparent; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
  background: var(--bg);
  color: var(--text);
  caret-color: var(--ink-blue);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
code, kbd, pre, samp { font-family: var(--font-mono); }
h1, h2, h3, h4 { font-family: var(--font-heading); text-wrap: balance; }
p { text-wrap: pretty; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
::selection { background: var(--page-yellow); color: var(--text); }
button, summary, label[for], select { cursor: pointer; }
button { touch-action: manipulation; }
img, svg, video { max-width: 100%; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 100;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  transition: top var(--dur) var(--ease-out);
}
.skip-link:focus { top: 8px; text-decoration: none; }
main.wrap:focus { outline: none; }
.ico { width: 16px; height: 16px; flex: none; }
.ico-lg { width: 20px; height: 20px; }
.ico-xl { width: 28px; height: 28px; }

/* 3 · shell — one top bar on every page, both hosts ----------------------- */
header.top {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: var(--header-bg);
  color: var(--header-text);
  border-bottom: 1px solid var(--header-line);
}
header.top .inner {
  display: flex;
  align-items: stretch;
  gap: var(--space-lg);
  min-height: var(--top-h);
  padding: 0 var(--gutter);
}
header.top a { color: inherit; text-decoration: none; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  flex: none;
  color: var(--text);
  font-size: var(--text-md);
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
header.top a.brand { color: var(--text); }
/* 竖屏 9:16 frame with a play notch */
.brand-mark {
  position: relative;
  flex: none;
  width: 12px;
  height: 20px;
  border: 2px solid currentColor;
  border-radius: var(--radius-sm);
}
.brand-mark::after {
  content: "";
  position: absolute;
  left: 2.5px;
  top: 50%;
  margin-top: -3.5px;
  border-left: 5px solid currentColor;
  border-top: 3.5px solid transparent;
  border-bottom: 3.5px solid transparent;
}
.brand-tag {
  padding: 0 6px;
  border: 1px solid currentColor;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0.08em;
}
/* the sections never push into the account menu: when they do not fit they scroll sideways inside their own box
   (shell.js starts with the current one in view). Focus ring drawn inside, because a scrolling box clips what sticks out. */
.top-nav { display: flex; align-items: stretch; min-width: 0; flex: 1 1 auto; overflow-x: auto; scrollbar-width: none; }
.top-nav::-webkit-scrollbar { display: none; }
.top-nav a:focus-visible { outline-offset: -2px; }
.top-nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 0 11px;
  color: var(--header-text);
  white-space: nowrap;
  transition: color var(--dur-fast) ease, background var(--dur-fast) ease;
}
.top-nav a:hover { color: var(--text); background: rgba(21, 23, 28, 0.06); }
.top-nav a[aria-current="page"] { color: var(--text); font-weight: 600; box-shadow: inset 0 -3px 0 var(--text); }
/* a new group starts here: the gap and the rule do the labelling */
.top-nav a.nav-g { margin-left: 19px; }
.top-nav a.nav-g::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 16px;
  bottom: 16px;
  width: 1px;
  background: var(--line-strong);
}
body.admin-host .top-nav a.nav-g::before { background: var(--rule-goldenrod); }
.top-end { display: flex; align-items: center; gap: var(--space-sm); flex: none; margin-left: auto; }
.top-end > a { display: inline-flex; align-items: center; min-height: var(--control-h); padding: 0 10px; border-radius: var(--radius-md); color: var(--header-text); }
.top-end > a:hover { color: var(--text); background: rgba(21, 23, 28, 0.06); }
header.top .top-end > a.nav-cta { background: var(--accent); color: var(--on-accent); font-weight: 600; padding: 0 14px; }
header.top .top-end > a.nav-cta:hover { background: var(--accent-hover); }
/* account menu: <details>, works without script; shell.js only adds outside-click and Esc */
.acct { position: relative; }
.acct > summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--control-h);
  max-width: 240px;
  padding: 0 8px 0 4px;
  border-radius: var(--radius-md);
  color: var(--text);
  list-style: none;
  user-select: none;
}
.acct > summary::-webkit-details-marker { display: none; }
.acct > summary:hover, .acct[open] > summary { background: rgba(21, 23, 28, 0.08); }
.acct-initial {
  display: grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: #ffffff;
  font-size: var(--text-xs);
  font-weight: 700;
}
.acct-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.acct > summary .ico { width: 12px; height: 12px; opacity: 0.7; }
.acct-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 60;
  min-width: 232px;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
.acct-who { margin: 0; padding: 6px 10px 10px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: var(--text-sm); overflow-wrap: anywhere; }
.acct-who b { display: block; color: var(--text); font-size: var(--text-base); font-weight: 600; }
header.top .acct-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-md);
  color: var(--text);
}
header.top .acct-menu a:hover { background: var(--surface-3); }
.acct-menu a .ico { color: var(--muted); }
.acct-menu hr { height: 1px; margin: 6px 0; border: 0; background: var(--line); }
.acct-who + a { margin-top: 6px; }

/* 4 · layout ------------------------------------------------------------- */
.wrap {
  display: block;
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--space-lg) var(--gutter) var(--space-3xl);
  flex: 1;
}
.wrap.wide { max-width: none; }
.wrap.narrow { max-width: 720px; }
/* page header: the title on the left, this page's one main action on the right */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
  flex-wrap: wrap;
  min-height: var(--control-h);
  margin: 0 0 var(--space-md);
}
.page-head h1 { margin: 0; font-size: var(--text-xl); line-height: 1.3; font-weight: 700; }
.page-head p { margin: 0; }
.page-tools { display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }
.row { display: flex; gap: var(--space-sm); flex-wrap: wrap; align-items: center; }
.sep { height: 1px; background: var(--line); margin: var(--space-12) 0; }

/* 5 · components --------------------------------------------------------- */
/* sheet: one sheet per subject; sheets never nest */
.card {
  margin-top: var(--space-md);
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
}
.page-head + .card, .flash + .card { margin-top: 0; }
.card h2 { margin: 0 0 var(--space-12); font-size: var(--text-lg); line-height: 1.4; font-weight: 700; }
.card h3 { margin: 0 0 var(--space-sm); font-size: var(--text-base); font-weight: 600; }
.card.flush { padding: 0; overflow: hidden; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  flex-wrap: wrap;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}
.card-head h2 { margin: 0; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-lg);
  margin-bottom: var(--space-md);
}
.section-head h2 { margin: 0; }
.section-head p { margin: 0; font-size: var(--text-sm); color: var(--muted); }
.muted { color: var(--muted); }
.hint { margin: 4px 0 0; font-size: var(--text-sm); line-height: 1.5; color: var(--muted); }
.mono { font-family: var(--font-mono); font-size: var(--text-sm); word-break: break-all; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.req { color: var(--err-text); font-weight: 700; }
form.inline { display: inline; }
.label-sm { display: block; margin-bottom: 2px; font-size: var(--text-xs); font-weight: 600; color: var(--muted); }
/* flash: a slip across the top of the page */
.flash {
  margin: 0 0 var(--space-md);
  padding: 8px 12px;
  border: 1px solid var(--rule-gray);
  border-radius: var(--radius-md);
  background: var(--page-gray);
  color: var(--text);
  font-weight: 500;
}
.flash.ok { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok-text); }
.flash.err { background: var(--err-soft); border-color: var(--err-line); color: var(--err-text); }
/* fields: label above, ruled box, blue-ink focus */
label { display: block; margin: var(--space-12) 0 4px; font-size: var(--text-sm); font-weight: 600; color: var(--text-2); }
input[type=text], input[type=email], input[type=password], input[type=search],
input[type=number], input[type=url], input[type=date], textarea, select {
  width: 100%;
  min-height: var(--control-h);
  padding: 5px 10px;
  border: 1px solid var(--field-line);
  border-radius: var(--radius-md);
  background: var(--field);
  color: var(--text);
  font: inherit;
  font-size: var(--text-base);
  line-height: 1.4;
  transition: border-color var(--dur-fast) ease;
}
input:hover, textarea:hover, select:hover { border-color: var(--field-line-hover); }
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: -1px;
  border-color: var(--ring);
}
input::placeholder, textarea::placeholder { color: var(--placeholder); opacity: 1; }
input:disabled, textarea:disabled, select:disabled { background: var(--surface-3); color: var(--faint); cursor: not-allowed; }
textarea { min-height: 96px; padding: 8px 10px; resize: vertical; line-height: 1.6; }
textarea.mono, textarea.links { font-family: var(--font-mono); font-size: var(--text-sm); line-height: 1.7; }
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 256 256' fill='%23565c68'%3E%3Cpath d='M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
select option { background: var(--surface); color: var(--text); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); cursor: pointer; }
/* buttons: one ink button per zone; everything else is ruled paper or bare text */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--control-h);
  padding: 4px 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--dur-fast) ease, border-color var(--dur-fast) ease, color var(--dur-fast) ease;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); text-decoration: none; }
.btn:active { background: #000000; border-color: #000000; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn:disabled:hover { background: var(--accent); border-color: var(--accent); }
.btn .ico { width: 16px; height: 16px; }
.btn.secondary, .btn.ghost { background: var(--btn2-bg); border-color: var(--field-line); color: var(--text); }
.btn.secondary:hover, .btn.ghost:hover { background: var(--btn2-bg-hover); border-color: var(--text); color: var(--text); }
.btn.secondary:active, .btn.ghost:active { background: var(--line); }
.btn.secondary:disabled:hover, .btn.ghost:disabled:hover { background: var(--btn2-bg); border-color: var(--field-line); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.quiet:hover { background: var(--btn2-bg-hover); border-color: transparent; color: var(--text); }
.btn.quiet:active { background: var(--line); }
.btn.danger { background: var(--err); border-color: var(--err); color: var(--on-err); }
.btn.danger:hover { background: #821419; border-color: #821419; color: var(--on-err); }
.btn.sm { min-height: 28px; padding: 2px 10px; font-size: var(--text-sm); }
.btn.sm .ico { width: 14px; height: 14px; }
.btn-lg { min-height: 40px; padding: 8px 20px; font-size: var(--text-md); }
.btn.icon { width: var(--control-h); padding: 0; }
/* 色页 slip: a status is a rectangle of its page colour with the state in words */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 0 6px; border-radius: var(--radius-sm); background: var(--p, var(--page-gray)); color: var(--p-ink, var(--ink-gray)); font-size: var(--text-xs); font-weight: 600; line-height: 1.7; white-space: nowrap; vertical-align: middle; }
.badge.queued, .badge.pending { --p: var(--page-yellow); --p-ink: var(--ink-yellow); }
.badge.processing { --p: var(--page-blue); --p-ink: var(--ink-blue); }
.badge.done, .badge.approved { --p: var(--page-green); --p-ink: var(--ink-green); }
.badge.failed, .badge.rejected { --p: var(--page-cherry); --p-ink: var(--ink-cherry); }/* tables: ruled like a call sheet — an ink rule under the head, hairlines between rows */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th {
  border-bottom: 1px solid var(--text);
  color: var(--text-2);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
  vertical-align: bottom;
}
tbody tr:last-child > td { border-bottom: 0; }
tbody tr:hover > td { background: var(--row-hover); }
td.num, th.num { text-align: right; }
.empty-state { padding: var(--space-xl) var(--space-md); text-align: center; color: var(--muted); }
/* segmented choice: views, modes, filters — the pressed segment is the filled one */
.seg { display: inline-flex; flex: none; overflow: hidden; border: 1px solid var(--line-strong); border-radius: var(--radius-md); background: var(--surface); }
.seg > a, .seg > button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 12px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: var(--text-sm);
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}
.seg > a + a, .seg > button + button { border-left: 1px solid var(--line); }
.seg > a:hover, .seg > button:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.seg > .selected, .seg > [aria-pressed="true"], .seg > [aria-current="page"], .seg > [aria-selected="true"] { background: var(--surface-3); color: var(--text); font-weight: 600; }
/* dialogs share one frame */
dialog { color: var(--text); }
dialog::backdrop { background: var(--scrim); }

/* 6 · pages -------------------------------------------------------------- */
/* shared page pieces */
.page-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; color: var(--muted); font-size: var(--text-sm); }
.page-jump { display: flex; flex-wrap: wrap; gap: 2px; }
.page-jump a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--control-h);
  padding: 0 10px;
  border-radius: var(--radius-md);
  color: var(--text-2);
}
.page-jump a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.cell-sub { margin-top: 1px; font-size: var(--text-xs); }
.cell-err { color: var(--err-text); }
.kv-k { display: inline-block; min-width: 2.6em; margin-right: 6px; color: var(--muted); }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 var(--space-12); }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.field-row { display: flex; gap: var(--space-sm); }
.field-row > input { flex: 1 1 auto; min-width: 0; }
.form-end { display: flex; justify-content: flex-end; gap: var(--space-sm); margin-top: var(--space-md); }
label.check { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; color: var(--text); }
.pwd, .file-key {
  padding: 1px 6px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
}
.file-key { font-weight: 400; word-break: break-all; }
.unnamed { color: var(--muted); }
/* a row's rare form stays folded into the row until asked for */
.reveal > summary {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--field-line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  list-style: none;
  user-select: none;
}
.reveal > summary::-webkit-details-marker { display: none; }
.reveal > summary:hover { background: var(--surface-3); border-color: var(--text); }
.reveal[open] > summary { background: var(--surface-3); border-color: var(--text); }
.reveal > form { display: flex; flex-direction: column; gap: 6px; min-width: 200px; margin-top: 8px; }
.reveal > form.pw-reset { flex-direction: row; flex-wrap: wrap; align-items: center; }
.reveal > form.pw-reset input { flex: 1 1 150px; width: auto; min-height: 28px; padding: 2px 8px; font-size: var(--text-sm); }
.reveal > form.job-result input:not([type=checkbox]) { min-height: 28px; padding: 2px 8px; font-size: var(--text-sm); }
.pager { display: flex; align-items: center; gap: var(--space-sm); font-size: var(--text-sm); }
[id$="-toast"].flash {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 80;
  max-width: min(420px, 92vw);
  margin: 0;
  box-shadow: var(--shadow-lg);
}

/* sign in · sign up — the one place the 色页 are drawn rather than used */
.auth {
  display: grid;
  grid-template-columns: minmax(0, 380px) minmax(0, 420px);
  justify-content: center;
  align-items: center;
  gap: var(--space-3xl);
  min-height: min(70vh, 640px);
  padding-top: var(--space-xl);
}
.auth-card { margin: 0; padding: 28px; }
.auth-card h1 { margin: 0 0 var(--space-sm); font-size: var(--text-2xl); line-height: 1.2; font-weight: 700; }
.auth-form input { min-height: 40px; font-size: var(--text-lg); }
.auth-actions { display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); margin-top: var(--space-lg); }
.auth-actions .btn { min-width: 112px; }
.auth-after { display: flex; align-items: center; gap: var(--space-sm); margin: var(--space-md) 0 0; padding-top: var(--space-md); border-top: 1px solid var(--line); color: var(--muted); font-size: var(--text-sm); }
/* nine 9:16 sheets, stepped like a stack of revisions, in the order they are issued */
.pages { position: relative; aspect-ratio: 1 / 1; width: 100%; max-width: 420px; }
.pages i { position: absolute; left: 3%; top: 2%; width: 42%; aspect-ratio: 9 / 16; border: 1px solid var(--text); border-radius: var(--radius-md); background: var(--c); transform: translate(calc(var(--n) * 15%), calc(var(--n) * 4%)); }
.pages i:nth-child(1) { --n: 8; --c: var(--page-cherry); }
.pages i:nth-child(2) { --n: 7; --c: var(--page-salmon); }
.pages i:nth-child(3) { --n: 6; --c: var(--page-buff); }
.pages i:nth-child(4) { --n: 5; --c: var(--page-goldenrod); }
.pages i:nth-child(5) { --n: 4; --c: var(--page-green); }
.pages i:nth-child(6) { --n: 3; --c: var(--page-yellow); }
.pages i:nth-child(7) { --n: 2; --c: var(--page-pink); }
.pages i:nth-child(8) { --n: 1; --c: var(--page-blue); }
.pages i:nth-child(9) { --n: 0; --c: var(--surface); }
.pages i:nth-child(9)::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  margin: -14px 0 0 -9px;
  border-left: 22px solid var(--text);
  border-top: 14px solid transparent;
  border-bottom: 14px solid transparent;
}

/* 剧目目录 · 目录管理 */
.share-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.share-k { color: var(--muted); font-size: var(--text-sm); }
.share-row .share-link { margin-right: 12px; font-weight: 600; }
.share-acts { display: inline-flex; gap: 4px; margin-left: auto; }
.search-bar { display: flex; flex-wrap: wrap; gap: var(--space-sm); padding: 12px 16px; }
.search-bar input[type=search] { flex: 1 1 280px; width: auto; }
.card.flush .search-bar + .table-scroll, .card.flush .search-bar + .empty-state { border-top: 1px solid var(--line); }
.card.flush table th:first-child, .card.flush table td:first-child { padding-left: 16px; }
.card.flush table th:last-child, .card.flush table td:last-child { padding-right: 16px; }
.catalog-list td, .catalog-admin td { vertical-align: middle; }
.catalog-list .badge { margin-left: 6px; }
.inline-edit { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.inline-edit input { flex: 1 1 160px; width: auto; }
.row-missing > td { background: color-mix(in srgb, var(--page-cherry) 40%, var(--surface)); }

/* 用户审批 */
.admin-users td, .admin-jobs-table td { vertical-align: top; }
.admin-jobs-table .cell-scroll { max-width: 280px; max-height: 5.2em; margin-top: 2px; overflow: auto; font-size: var(--text-xs); overflow-wrap: anywhere; }
.admin-jobs-table .cell-baidu a { display: block; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-jobs-table .cell-share code { font-size: var(--text-xs); }
.btn.secondary.danger { background: var(--surface); border-color: var(--rule-cherry); color: var(--ink-cherry); }
.btn.secondary.danger:hover { background: var(--page-cherry); border-color: var(--ink-cherry); color: var(--ink-cherry); }

/* 热榜 */
.tik-bulk-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.tik-bulk-select-all { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; color: var(--text); }
.tik-bulk-bar .btn { margin-left: auto; }
.rankings-table th.num, .rankings-table td.num { width: 1%; white-space: nowrap; }
.rankings-table th.tik-check-col, .rankings-table td.tik-check-col { width: 1%; padding-right: 4px; text-align: center; }
.rankings-table td.rank { color: var(--muted); }
.rankings-table tbody tr:nth-child(-n+3) td.rank { color: var(--text); font-weight: 700; }
.rankings-table th .ico-sm { margin-left: 2px; vertical-align: -1px; }
.rankings-table .tik-actions { width: 1%; white-space: nowrap; }
.rankings-table .tik-actions > * + * { margin-left: 2px; }
.delta-up { color: var(--ok-text); }
.delta-down { color: var(--err-text); }dialog.tik-scrape-dialog { width: min(720px, 96vw); max-height: min(90vh, 900px); overflow: auto; }
.tik-scrape-dialog .share-confirm { margin-top: var(--space-md); }
@media (max-width: 640px) {
  .tik-scrape-dialog .delivery-grid { grid-template-columns: 1fr; }
}
.share-picker .badge { margin-left: 8px; }
.share-none { margin: 6px 8px; }

/* 7 · workbench /app ----------------------------------------------------- */
.wb-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-12) var(--space-lg);
}
.wb-head h1 { margin: 0; font-size: var(--text-xl); line-height: 1.3; font-weight: 700; letter-spacing: -0.01em; }
.wb-head p { margin: 6px 0 0; font-size: var(--text-sm); color: var(--muted); max-width: 52em; }
.wb-head .badge { margin-top: 4px; }

/* section jump links with live counts */
.wb-jump { display: flex; flex-wrap: wrap; gap: var(--space-sm); margin-top: var(--space-md); }
.wb-jump a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-2);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: border-color var(--dur) ease, color var(--dur) ease, background var(--dur) ease;
}
.wb-jump a .ico { color: var(--muted); transition: color var(--dur) ease; }
.wb-jump a:hover { border-color: var(--line-strong); color: var(--text); background: var(--surface-2); text-decoration: none; }
.wb-jump a:hover .ico { color: var(--accent-text); }
.wb-count, .wb-live { padding: 0 6px; border-radius: var(--radius-sm); font-size: var(--text-xs); font-weight: 600; line-height: 1.7; }
.wb-count { background: var(--surface-3); color: var(--muted); }
.wb-live { background: var(--info-soft); color: var(--info-text); }

/* notice (not approved) */
.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  margin-top: var(--space-lg);
  padding: 18px 20px;
  border: 1px solid var(--warn-line);
  border-radius: var(--radius-lg);
  background: var(--warn-soft);
}
.notice h2 { margin: 2px 0 4px; font-size: var(--text-base); font-family: var(--font-body); }
.notice p { margin: 0; color: var(--text-2); font-size: var(--text-sm); }
.notice-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--warn-line);
  border-radius: var(--radius-md);
  background: var(--bg-deep);
  color: var(--warn-text);
}
.notice-icon .ico { width: 20px; height: 20px; }
.notice-err { border-color: var(--err-line); background: var(--err-soft); }
.notice-err .notice-icon { color: var(--err-text); border-color: var(--err-line); }

/* submit form */
.job-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 0 var(--space-xl); }
.job-links label,
.job-meta .field:first-child label { margin-top: 0; }
.job-links textarea { min-height: 260px; }
.job-meta .field + .field label { margin-top: var(--space-md); }
.delivery-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md) var(--space-xl); margin-top: var(--space-lg); }
.delivery-fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.delivery-fieldset legend { margin: 0 0 8px; padding: 0; font-size: var(--text-sm); font-weight: 500; color: var(--text-2); }
.delivery-opts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-sm); }
.delivery-opt {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--field-line);
  border-radius: var(--radius-md);
  background: var(--field);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--dur) ease, background var(--dur) ease, box-shadow var(--dur) ease;
}
.delivery-opt:hover { border-color: var(--field-line-hover); }
.delivery-opt:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.delivery-opt:has(input:focus-visible) { box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px var(--focus-halo); }
.delivery-opt input[type=radio] { flex-shrink: 0; width: 16px; height: 16px; margin: 2px 0 0; }
.opt-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.opt-title { font-size: var(--text-sm); font-weight: 600; line-height: 1.4; }
.opt-sub { font-size: var(--text-xs); line-height: 1.4; color: var(--muted); }
.delivery-note { margin-top: var(--space-12); }
.form-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: var(--space-sm); margin-top: var(--space-md); padding-top: var(--space-md); border-top: 1px solid var(--line); }
.form-actions .hint { margin: 0 auto 0 0; }

/* share picker + recipients confirm (kept deliberately loud: missed recipients get no link) */
.share-picker {
  max-height: 228px;
  overflow-y: auto;
  margin-top: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}
.share-picker label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  padding: 8px 8px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 400;
  cursor: pointer;
  transition: background var(--dur-fast) ease;
}
.share-picker label:hover { background: var(--accent-soft); }
.share-picker input[type=checkbox] { width: 16px; height: 16px; margin-top: 3px; flex-shrink: 0; }
.share-self { opacity: 0.8; cursor: default !important; }
.share-self:hover { background: transparent !important; }
.share-confirm {
  margin-top: var(--space-lg);
  padding: var(--space-md) var(--space-md) var(--space-12);
  border: 1.5px solid var(--alarm);
  border-radius: var(--radius-lg);
  background: var(--alarm-soft);
  box-shadow: none;
}
.share-confirm-pulse { animation: sharePulse 0.9s ease-in-out 2; }
@keyframes sharePulse {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 0 3px var(--rule-pink); }
}
.share-confirm-banner { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; color: var(--alarm-text); }
.share-confirm-banner strong { font-size: var(--text-md); letter-spacing: 0.01em; }
.share-confirm-banner span { font-size: var(--text-sm); line-height: 1.5; font-weight: 500; }
.share-confirm-label { margin-top: 12px; color: var(--alarm-strong); font-weight: 600; }
.share-confirm-hint { color: var(--alarm-text); }
.share-confirm .share-picker { max-height: 228px; margin-top: 8px; padding: 0; border: 0; background: transparent; }
.share-confirm-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px dashed var(--alarm);
  border-radius: var(--radius-md);
  background: var(--alarm-soft-2);
  color: var(--alarm-strong);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
}
.share-confirm-check input[type=checkbox] { width: 16px; height: 16px; margin-top: 3px; flex-shrink: 0; accent-color: var(--alarm); }

/* my jobs */
.jobs-counts { display: flex; flex-wrap: wrap; gap: 6px; }
.jobs-table td { vertical-align: top; }
.jobs-table .col-id { width: 1%; color: var(--faint); font-size: var(--text-sm); white-space: nowrap; }
.jobs-table .num { white-space: nowrap; }
.jobs-table td.num { font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.jobs-table .col-act { width: 1%; white-space: nowrap; text-align: right; }
.jobs-table th.col-act { text-align: right; }
.th-note { margin-left: 6px; font-weight: 400; color: var(--faint); font-size: var(--text-xs); letter-spacing: 0; }
.job-title { min-width: 9em; font-weight: 600; color: var(--text); }
.job-genre { white-space: nowrap; }
.job-error { max-width: 22em; margin-top: 6px; font-size: var(--text-sm); line-height: 1.5; color: var(--err-text); overflow-wrap: anywhere; }
.job-delivery { font-size: var(--text-sm); white-space: nowrap; color: var(--text-2); }
.kv-k { display: inline-block; min-width: 2.4em; margin-right: 4px; color: var(--faint); }
.job-baidu { min-width: 150px; max-width: 240px; }
.job-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}
.job-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-link .ico { width: 14px; height: 14px; flex: none; }
.job-pwd { margin-top: 6px; font-size: var(--text-xs); color: var(--muted); }
.job-pwd .pwd { padding: 1px 6px; font-size: var(--text-xs); }
.job-failed > td { background: color-mix(in srgb, var(--page-cherry) 40%, var(--surface)); }
.empty-state p { margin: 0; }
.empty-state .hint { margin-top: 4px; }

/* 8 · 工作台 /app — CloudCLI-style three-pane workbench -------------------
   left  : sessions (one flat list of session rows, search, 新建会话)
   middle: header (title · service dot · views 对话 / 提交请求 / 我的任务) + the view
   right : the selected session's outputs/ (images + file tree)
   Wide: three panes, either side pane collapses. ≤1179px outputs = drawer;
   ≤899px sessions = drawer; ≤768px bottom bar replaces the view tabs. */
:root {
  --wb-side-bg: var(--bg);
  --wb-main-bg: var(--surface);
  --wb-hover: rgba(21, 23, 28, 0.06);
  --wb-soft: rgba(21, 23, 28, 0.035);
  --wb-current: var(--surface);
  --wb-current-line: var(--line-strong);
  --wb-head-h: 48px;
  --bubble: var(--page-blue);
  --on-bubble: var(--text);
  --bubble-meta: var(--muted);
}
body.page-app { height: 100vh; height: 100dvh; overflow: hidden; }
body.page-app header.top .inner { min-height: var(--top-h); }
body.page-app main.wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  max-width: none;
  padding: 0;
}
body.page-app .flash { flex: none; display: flex; align-items: center; gap: 12px; margin: 8px 12px; padding: 6px 6px 6px 12px; }
.flash-x { flex: none; margin-left: auto; width: 28px; height: 28px; padding: 0; border: 0; border-radius: var(--radius-md); background: transparent; color: inherit; font-size: var(--text-lg); line-height: 1; }
.flash-x:hover { background: var(--wb-hover); }
.ico-sm { width: 12px; height: 12px; }
.ico-caret { width: 12px; height: 12px; opacity: 0.7; }

/* 8.1 shell */
.wb {
  --wb-side-w: 280px;
  --wb-files-w: 320px;
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--wb-side-w) minmax(0, 1fr) var(--wb-files-w);
  grid-template-rows: minmax(0, 1fr);
  background: var(--wb-main-bg);
  overflow: hidden;
}
.wb[data-right="collapsed"],
.wb:not([data-tab="chat"]) { --wb-files-w: 0px; }
.wb[data-right="collapsed"] .wb-files,
.wb:not([data-tab="chat"]) .wb-files { display: none; }
.wb-scrim { position: absolute; inset: 0; z-index: 35; background: var(--scrim); }

/* 8.2 left: sessions */
.wb-side {
  grid-column: 1;
  grid-row: 1;
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--wb-side-bg);
  border-right: 1px solid var(--line);
}
.ws-head { flex: none; display: flex; align-items: center; gap: 8px; min-height: var(--wb-head-h); padding: 8px 8px 8px 12px; }.ws-name { flex: 1; margin: 0; color: var(--text); font-size: var(--text-base); font-weight: 700; }
.ws-sub { margin: 2px 0 0; overflow: hidden; color: var(--muted); font-size: var(--text-xs); line-height: 1.3; white-space: nowrap; text-overflow: ellipsis; }
.ws-tools { flex: none; display: flex; gap: 2px; }
.ws-icon { position: relative; display: inline-grid; place-items: center; width: var(--control-h); height: var(--control-h); padding: 0; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--muted); transition: background var(--dur-fast) ease, color var(--dur-fast) ease; }
.ws-icon:hover { background: var(--wb-hover); color: var(--text); }
.ws-icon:disabled { opacity: 0.4; cursor: not-allowed; background: transparent; color: var(--muted); }
.ws-close { display: none; }

.ws-search { position: relative; flex: none; margin: 0 12px 8px; }
.ws-search > .ico {
  position: absolute;
  top: 50%;
  left: 11px;
  width: 15px;
  height: 15px;
  color: var(--faint);
  transform: translateY(-50%);
  pointer-events: none;
}
.ws-search input[type=search] { padding-left: 32px; border-color: var(--line-strong); }.ws-filter { flex: none; display: flex; margin: 0 12px 4px; border: 1px solid var(--line-strong); border-radius: var(--radius-md); background: var(--surface); overflow: hidden; }
.ws-filter-btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 28px; padding: 2px 8px; border: 0; border-radius: 0; background: transparent; color: var(--muted); font: inherit; font-size: var(--text-sm); font-weight: 500; transition: background var(--dur-fast) ease, color var(--dur-fast) ease; }
.ws-filter-btn:hover { color: var(--text); }
.ws-filter-btn[aria-pressed="true"] { background: var(--surface-3); color: var(--text); font-weight: 600; }
.ws-filter-n { color: var(--faint);  font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
.ws-filter-n:empty { display: none; }

.ws-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px 8px 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.ws-sessions { margin: 0; padding: 0; list-style: none; }
.ws-row { position: relative; margin: 2px 0; }
.ws-open {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  width: 100%;
  min-height: 48px;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--text-2);
  font: inherit;
  text-align: left;
  transition: background var(--dur-fast) ease, border-color var(--dur-fast) ease, color var(--dur-fast) ease;
}
.ws-open:hover { background: var(--wb-hover); color: var(--text); }
.ws-open[aria-current="true"] { border-color: var(--wb-current-line); background: var(--wb-current); color: var(--text); }
.ws-ico { position: relative; flex: none; display: inline-flex; margin-top: 2px; color: var(--faint); }
.ws-open[aria-current="true"] .ws-ico { color: var(--info-text); }
.ws-row[data-state="busy"] .ws-ico { color: var(--info-text); }
.ws-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ws-line { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.ws-title { flex: 1 1 auto; min-width: 0; overflow: hidden; color: inherit; font-size: var(--text-base); font-weight: 500; line-height: 1.4; white-space: nowrap; text-overflow: ellipsis; }
.ws-open[aria-current="true"] .ws-title { font-weight: 600; }
.ws-time { flex: none; color: var(--faint); font-size: var(--text-xs); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ws-sub { align-items: center; color: var(--faint); font-size: var(--text-xs); line-height: 1.4; }
.ws-state { display: inline-flex; align-items: center; gap: 5px; min-width: 0; font-weight: 500; white-space: nowrap; }
.ws-state::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.ws-row[data-state="busy"] .ws-state { color: var(--info-text); }
.ws-row[data-state="ok"] .ws-state { color: var(--ok-text); }
.ws-row[data-state="err"] .ws-state { color: var(--err-text); }
.ws-row[data-state="warn"] .ws-state { color: var(--warn-text); }
.ws-row[data-state="draft"] .ws-state::before { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }
.ws-files { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ws-files .ico { width: 12px; height: 12px; }
.ws-count { flex: none; min-width: 22px; margin-left: auto; padding: 0 6px; border-radius: var(--radius-sm); background: var(--surface-3); color: var(--muted); font-size: var(--text-xs); line-height: 18px; text-align: center; font-variant-numeric: tabular-nums; }
/* row actions: "⋯" sits where the message count is, shown on hover / keyboard focus */
.ws-more {
  position: absolute;
  right: 6px;
  bottom: 6px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--surface-3);
  color: var(--text-2);
  opacity: 0;
  transition: opacity var(--dur-fast) ease, background var(--dur-fast) ease;
}
.ws-row:hover .ws-more,
.ws-row:focus-within .ws-more,
.ws-more[aria-expanded="true"] { opacity: 1; }
.ws-row:hover .ws-count,
.ws-row:focus-within .ws-count,
.ws-row:has(.ws-more[aria-expanded="true"]) .ws-count { visibility: hidden; }
.ws-more:hover { background: var(--line-strong); color: var(--text); }
/* finished in the background while you were elsewhere: a dot on the row's icon (busy rows spin instead) */
.ws-row.is-unseen .ws-ico::after {
  content: "";
  position: absolute;
  top: -3px;
  right: -4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 2px var(--wb-side-bg);
}
.ws-empty { margin: 6px 4px; padding: 8px; color: var(--faint); font-size: var(--text-sm); line-height: 1.55; list-style: none; }
.ws-more-sessions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 34px;
  margin: 2px 0 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: var(--text-sm);
}
.ws-more-sessions:hover { background: var(--wb-hover); color: var(--text); }.ws-new-btn { flex: 1 1 auto; min-width: 0; }
.ws-locked { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 8px 4px; padding: 16px 12px; border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); color: var(--muted); font-size: var(--text-sm); line-height: 1.55; text-align: center; }
.ws-locked p { margin: 0; }
.ws-locked-ico { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-md); background: var(--page-yellow); color: var(--ink-yellow); }
.ws-locked-title { color: var(--text-2); font-size: var(--text-base); font-weight: 600; }
.ws-locked-act { margin-top: 8px; }
.ws-foot { flex: none; }
.ws-user { display: none; align-items: center; gap: 10px; min-width: 0; padding: 10px 12px; border-top: 1px solid var(--line); }
.ws-avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 700;
}
.ws-user-text { flex: 1; min-width: 0; }
.ws-user-name, .ws-user-mail { margin: 0; overflow: hidden; line-height: 1.35; white-space: nowrap; text-overflow: ellipsis; }
.ws-user-name { color: var(--text); font-size: var(--text-sm); font-weight: 600; }
.ws-user-mail { color: var(--faint); font-size: var(--text-xs); }
.ws-links { display: flex; flex-wrap: wrap; gap: 2px; padding: 8px 12px; border-top: 1px solid var(--line); }.ws-links:not(:has(.ws-link:not(.ws-site):not([hidden]))) { display: none; }
.ws-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 8px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: var(--text-sm);
}
.ws-link:hover { background: var(--wb-hover); color: var(--text); text-decoration: none; }
.ws-link .ico { width: 15px; height: 15px; }
.ws-site { display: none; }
.ws-rail { display: none; }

/* 8.3 middle: header + views */
.wb-main { grid-column: 2; grid-row: 1; position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.wm-head { flex: none; display: flex; align-items: stretch; gap: 12px; min-height: var(--wb-head-h); padding: 0 12px 0 8px; border-bottom: 1px solid var(--line); background: var(--wb-main-bg); }
.wm-icon { flex: none; align-self: center; position: relative; display: inline-grid; place-items: center; width: var(--control-h); height: var(--control-h); padding: 0; border: 1px solid var(--line-strong); border-radius: var(--radius-md); background: transparent; color: var(--text-2); transition: background var(--dur-fast) ease, color var(--dur-fast) ease; }
.wm-icon:hover { background: var(--wb-hover); color: var(--text); }
.wm-icon[aria-expanded="true"] { background: var(--surface-3); color: var(--text); }
.wm-menu { display: none; }
.wm-files-btn { display: none; }
.wb[data-right="collapsed"][data-tab="chat"] .wm-files-btn { display: inline-grid; }
.wm-badge { position: absolute; top: -6px; right: -6px; min-width: 18px; padding: 0 5px; border-radius: var(--radius-sm); background: var(--accent); color: var(--on-accent);  font-size: var(--text-xs); font-weight: 700; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px var(--wb-main-bg); }
.wm-badge:empty { display: none; }
.wm-title { flex: 1 1 auto; align-self: center; min-width: 0; padding-left: 4px; }.wm-title-chat { display: flex; align-items: baseline; gap: 12px; min-width: 0; }.wb[data-tab="submit"] .wm-title-chat,
.wb[data-tab="jobs"] .wm-title-chat { display: none; }input.wm-title-input { flex: 1 1 8em; width: auto; min-width: 4em; min-height: 28px; margin: 0; padding: 1px 6px; border: 1px solid transparent; background: transparent; color: var(--text); font-size: var(--text-base); font-weight: 600; text-overflow: ellipsis; }
input.wm-title-input:hover { border-color: var(--line-strong); }
input.wm-title-input:focus { border-color: var(--ring); background: var(--field); }
input.wm-title-input.is-auto::placeholder { color: var(--text); opacity: 1; }
input.wm-title-input:focus::placeholder { color: var(--placeholder); }
input.wm-title-input:disabled { background: transparent; color: var(--text); cursor: default; }
.wm-title-text { margin: 0; overflow: hidden; color: var(--text); font-size: var(--text-base); font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.wm-sub { flex: none; display: flex; align-items: center; gap: 12px; max-width: 60%; overflow: hidden; color: var(--muted); font-size: var(--text-sm); white-space: nowrap; }
.wm-sub > span { flex: none; }
.wm-sub > span:last-child { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.wm-pv { display: inline-flex; align-items: center; gap: 5px; color: var(--text-2); font-weight: 500; }
.wm-pv .ico { width: 13px; height: 13px; }
.wm-right { display: contents; }
.wm-head .cx-gw { order: 3; align-self: center; }
.wm-tabs { order: -1; display: flex; align-items: stretch; }
.wm-tab { display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; border: 0; border-radius: 0; background: transparent; color: var(--muted); font: inherit; font-size: var(--text-base); white-space: nowrap; transition: color var(--dur-fast) ease, background var(--dur-fast) ease; }
.wm-tab:hover { background: var(--wb-hover); color: var(--text); }
.wm-tab[aria-selected="true"] { color: var(--text); font-weight: 600; box-shadow: inset 0 -3px 0 var(--text); }
.wm-tab .ico { display: none; }
.wm-panels { position: relative; flex: 1 1 auto; min-height: 0; }
.wm-panel { position: absolute; inset: 0; display: flex; flex-direction: column; min-height: 0; }
.wm-panel:focus { outline: none; }
.wb.js .wm-panel { display: none; }
.wb.js[data-tab="chat"] .wm-panel[data-panel="chat"],
.wb.js[data-tab="submit"] .wm-panel[data-panel="submit"],
.wb.js[data-tab="jobs"] .wm-panel[data-panel="jobs"] { display: flex; }
.wb:not(.js) .wm-panels { overflow-y: auto; }
.wb:not(.js) .wm-panel { position: static; display: block; }
.wm-docpanel { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.wm-doc { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 24px 40px; }
.wm-doc > .card { margin-top: 0; padding: 16px 0 0; border: 0; border-radius: 0; background: transparent; }
/* the view title already sits in the header: keep the card's h2 for screen readers only */.wm-doc .section-head { margin-bottom: var(--space-12); }

/* bottom bar (phones) */
.wb-bottom {
  display: none;
  flex: none;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 2px;
  padding: 4px 6px 6px;
  border-top: 1px solid var(--line);
  background: var(--wb-side-bg);
}
.wb-bn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 52px;
  padding: 4px 2px;
  border: 0;
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 500;
}
.wb-bn .ico { width: 21px; height: 21px; }
.wb-bn[aria-current="page"] { color: var(--text); background: var(--surface-3); font-weight: 600; }
.wb-bn-badge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 17px; padding: 0 4px; border-radius: var(--radius-sm); background: var(--surface-3); color: var(--text); font-size: var(--text-xs); font-style: normal; font-weight: 700; line-height: 17px; text-align: center; }
.wb-bn-badge:empty { display: none; }
.wb-bn-badge.is-live { background: var(--info-soft); color: var(--info-text); }

/* 8.4 right: session outputs */
.wb-files {
  grid-column: 3;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--wb-side-bg);
  border-left: 1px solid var(--line);
}
.wf-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: var(--wb-head-h);
  padding: 8px 8px 8px 16px;
  border-bottom: 1px solid var(--line);
}
.wf-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
}
.wf-head h2 > .ico { color: var(--muted); }
.wf-tools { display: flex; gap: 2px; }
.ws-icon[aria-busy="true"] .ico { animation: cxSpin 0.9s linear infinite; }
.wf-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.wf-sec h3 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 8px;
  color: var(--faint);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.03em;
}
.wf-sec h3 .ico { width: 14px; height: 14px; }
.wf-tree .wf-list { margin: 0; padding: 0; list-style: none; }
.wf-tree .wf-list .wf-list { margin-left: 15px; padding-left: 6px; border-left: 1px solid var(--line); }
.wf-row { display: flex; align-items: center; gap: 7px; width: 100%; min-height: 34px; padding: 5px 8px; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text-2); font: inherit; font-size: var(--text-sm); text-align: left; transition: background var(--dur-fast) ease, color var(--dur-fast) ease; }
.wf-row:hover { background: var(--wb-hover); color: var(--text); text-decoration: none; }
.wf-row .ico { flex: none; width: 15px; height: 15px; color: var(--faint); }
.wf-row.is-dir .ico:first-child { width: 12px; height: 12px; }
.wf-row.is-dir .ico:nth-child(2) { color: var(--warn-text); opacity: 0.85; }
.wf-row.is-file .ico:first-child { color: var(--info-text); opacity: 0.85; }
.wf-name { flex: 1; min-width: 0; overflow: hidden; font-size: var(--text-sm); white-space: nowrap; text-overflow: ellipsis; }
.wf-size, .wf-meta { flex: none; color: var(--faint); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
.wf-row .wf-dl { opacity: 0; transition: opacity var(--dur-fast) ease; }
.wf-row:hover .wf-dl, .wf-row:focus-visible .wf-dl { opacity: 1; color: var(--accent-text); }
@media (hover: none) { .wf-row .wf-dl { opacity: 0.8; } .ws-more { opacity: 1; } .ws-count { visibility: hidden; } }
/* flat skill-job outputs: always show download affordance */
.wf-tree.is-flat-outputs .wf-row .wf-dl { opacity: 0.85; }
.wf-tree.is-flat-outputs .wf-row.is-file { cursor: pointer; }
.wf-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: auto 0;
  padding: 16px 8px;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.6;
  text-align: center;
}
.wf-empty p { margin: 0; }
.wf-empty .ico { color: var(--line-strong); }
.wf-empty-title { color: var(--text-2); font-size: var(--text-base); font-weight: 600; }
/* 8.5 conversation */
.wm-chat { background: var(--wb-main-bg); }
.cx-lock-note {
  flex: none;
  margin: 12px 24px 0;
  padding: 10px 14px;
  border: 1px solid var(--err-line);
  border-radius: var(--radius-md);
  background: var(--err-soft);
  color: var(--err-text);
  font-size: var(--text-sm);
  font-weight: 500;
}
.cx-window { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
/* a thin running bar instead of a glowing frame */
.cx-window::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--info) 50%, transparent);
  background-size: 45% 100%;
  background-repeat: no-repeat;
  opacity: 0;
  pointer-events: none;
}
.cx-window:is([data-state="creating"], [data-state="submitting"], [data-state="queued"], [data-state="running"],
  [data-state="tools"], [data-state="continuing"], [data-state="imaging"])::before { opacity: 1; }
.cx-thread {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 26px 24px 18px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.cx-thread:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
.cx-col { width: 100%; max-width: 860px; margin: 0 auto; }
.cx-thread > .cx-col { min-height: 100%; display: flex; flex-direction: column; }
.cx-turns { display: flex; flex-direction: column; gap: 26px; margin: 0; padding: 0; list-style: none; }
.cx-turns:empty { display: none; }
.cx-turn { min-width: 0; }

/* empty session: a short welcome; the assistant is picked from the composer chip */
.cx-intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: auto 0;
  padding: 12px 0 18px;
  text-align: center;
}
.cx-intro-logo { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: 12px; border-radius: var(--radius-md); background: var(--surface-3); color: var(--text); }
.cx-intro-logo .ico { width: 24px; height: 24px; }
.cx-intro-logo[data-provider="claude"] { background: var(--page-salmon); color: var(--ink-salmon); }
.cx-intro-title { margin: 0; color: var(--text); font-size: var(--text-xl); font-weight: 700; }.cx-intro .notice { width: 100%; max-width: 560px; margin: 0 0 6px; text-align: left; }.cx-intro-hint .ico { width: 13px; height: 13px; }
.cx-intro-note { max-width: 40em; margin: 12px 0 0; padding: 6px 12px; border: 1px solid var(--warn-line); border-radius: var(--radius-md); background: var(--warn-soft); color: var(--warn-text); font-size: var(--text-sm); }
.cx-intro .cx-examples { justify-content: center; margin-top: 18px; }

/* user turns: blue bubble + avatar on the right */
.cx-turn.is-user,
.cx-turn-user { display: flex; justify-content: flex-end; align-items: flex-end; gap: 10px; }
.cx-user-col { display: flex; flex-direction: column; align-items: flex-end; min-width: 0; max-width: min(80%, 640px); }
.cx-bubble { max-width: 100%; padding: 8px 14px 6px; border-radius: var(--radius-lg); background: var(--bubble); color: var(--on-bubble); font-size: var(--text-md); line-height: 1.65; }
.cx-bubble-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.cx-bubble-time { display: block; margin-top: 3px; color: var(--bubble-meta); font-size: var(--text-xs); text-align: right; font-variant-numeric: tabular-nums; }
.cx-bubble-tag { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 4px; color: var(--ink-blue); font-size: var(--text-xs); font-weight: 600; }
.cx-bubble-tag .ico { width: 14px; height: 14px; }
.cx-uavatar { flex: none; display: grid; place-items: center; width: 28px; height: 28px; margin-bottom: 2px; border-radius: var(--radius-sm); background: var(--text); color: #ffffff; font-size: var(--text-xs); font-weight: 700; }
.cx-turn-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 4px 10px; margin-top: 6px; padding: 0 2px; color: var(--faint); font-size: var(--text-xs); }
.cx-turn-meta .is-err { color: var(--err-text); }
.cx-turn-meta .is-ok { color: var(--ok-text); }
.cx-strip { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.cx-strip-img {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-deep);
  color: var(--faint);
  cursor: zoom-in;
}
.cx-strip-img:disabled { cursor: default; }
.cx-strip-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cx-strip.is-small { justify-content: center; margin-top: 6px; }
.cx-strip.is-small .cx-strip-img { width: 34px; height: 34px; border-color: var(--line); }
/* direct image request: a quieter bubble + the tool result under it */
.cx-turn.is-image .cx-bubble { border: 1px solid var(--rule-blue); background: var(--page-blue); color: var(--text); box-shadow: none; }
.cx-turn.is-image .cx-bubble-time { color: var(--faint); }
.cx-turn.is-image .cx-bubble-tag { color: var(--info-text); }
.cx-tool-row { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 0 12px; margin-top: 14px; }

/* assistant turns: avatar + name row, body full width */
.cx-agent-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; min-height: 34px; margin-bottom: 8px; color: var(--muted); font-size: var(--text-sm); }
.cx-avatar { display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--radius-sm); background: var(--surface-3); color: var(--text); }
.cx-avatar.is-tool { background: var(--info-soft); color: var(--info-text); }
.cx-agent-name { color: var(--text); font-size: var(--text-md); font-weight: 600; }
.cx-agent-round { padding: 0 6px; border-radius: var(--radius-sm); background: var(--page-gray); color: var(--ink-gray); font-size: var(--text-xs); font-weight: 600; line-height: 1.7; }
.cx-run-id { color: var(--faint); font-size: var(--text-xs); }
.cx-turn-time { margin-left: auto; color: var(--faint); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
.cx-agent-body { min-width: 0; }
.cx-agent-note { margin: 8px 0 0; color: var(--warn-text); font-size: var(--text-sm); }
.cx-agent-err {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 8px 0 0;
  padding: 9px 12px;
  border: 1px solid var(--err-line);
  border-radius: var(--radius-md);
  background: var(--err-soft);
  color: var(--err-text);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}
.cx-agent-err .ico { margin-top: 3px; }
.cx-agent-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; margin-top: 8px; }
.cx-ai-label { display: inline-flex; align-items: center; gap: 6px; margin-right: auto; color: var(--faint); font-size: var(--text-xs); font-weight: 500; }
.cx-ai-label .ico { width: 14px; height: 14px; color: var(--accent-text); }
.wm-chat.is-busy :is([data-act="rerun"], [data-act="resend"], [data-act="resume"]),
.wm-chat.is-locked :is([data-act="rerun"], [data-act="resend"], [data-act="resume"]) { display: none; }

/* markdown-lite output (AI generated) */
.cx-md { color: var(--text-2); font-size: var(--text-md); line-height: 1.75; overflow-wrap: anywhere; }
.cx-md p, .cx-md ul, .cx-md ol, .cx-md blockquote, .cx-md pre { margin: 0 0 10px; }
.cx-md > :last-child { margin-bottom: 0; }
.cx-md ul, .cx-md ol { padding-left: 1.4em; }
.cx-md ul { list-style: disc; }   /* turns live in an <ol>; don't inherit nested-list circles */
.cx-md ol { list-style: decimal; }
.cx-md li + li { margin-top: 3px; }
.cx-md li::marker { color: var(--faint); }
.cx-md strong { color: var(--text); font-weight: 600; }
.cx-md .cx-h { margin: 16px 0 6px; color: var(--text); font-size: var(--text-md); font-weight: 600; line-height: 1.5; }
.cx-md .cx-h1 { font-size: var(--text-lg); }
.cx-md > .cx-h:first-child { margin-top: 0; }
.cx-md code { padding: 1px 6px; border-radius: var(--radius-md); background: var(--surface-3); color: var(--text); font-size: 0.86em; }
.cx-md pre.cx-code {
  padding: 10px 12px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--code-bg);
  font-size: var(--text-sm);
  line-height: 1.65;
}
.cx-md pre.cx-code code { padding: 0; background: none; font-size: inherit; white-space: pre; }
.cx-md blockquote { padding-left: 12px; border-left: 3px solid var(--line-strong); color: var(--muted); }
.cx-md hr { margin: 14px 0; border: 0; border-top: 1px solid var(--line); }
.cx-md-img {
  display: inline-block;
  max-width: 220px;
  margin: 4px 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-3);
  vertical-align: top;
  cursor: zoom-in;
}
.cx-md-img img { display: block; max-width: 100%; max-height: 280px; object-fit: contain; }
.cx-md-img:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

/* tool call card (CloudCLI "Using …" → parameters → tool result) */
.cx-tool { max-width: 680px; margin: 12px 0; overflow: hidden; border: 1px solid var(--line-strong); border-radius: var(--radius-lg); background: var(--surface); transition: border-color var(--dur-slow) ease; }
.cx-tool-row .cx-tool { margin: 0; }
.cx-tool[data-state="error"] { border-color: var(--err-line); }
.cx-tool[data-state="skipped"] { border-color: var(--warn-line); }
.cx-tool-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; padding: 10px 12px 8px; color: var(--text); font-size: var(--text-sm); }
.cx-tool-ico { display: grid; place-items: center; width: 22px; height: 22px; border-radius: var(--radius-sm); background: var(--info-soft); color: var(--info-text); }
.cx-tool-ico .ico { width: 14px; height: 14px; }
.cx-tool-name { color: var(--text); font-size: var(--text-base); font-weight: 600; }
.cx-tool-params { color: var(--muted); font-size: var(--text-xs); }
.cx-tool-state { margin-left: auto; padding: 0 6px; border-radius: var(--radius-sm); background: var(--page-gray); color: var(--ink-gray); font-size: var(--text-xs); font-weight: 600; line-height: 1.7; }
.cx-tool:is([data-state="running"], [data-state="queued"]) .cx-tool-state { background: var(--info-soft); color: var(--info-text); }
.cx-tool[data-state="done"] .cx-tool-state { background: var(--ok-soft); color: var(--ok-text); }
.cx-tool[data-state="error"] .cx-tool-state { background: var(--err-soft); color: var(--err-text); }
.cx-tool[data-state="skipped"] .cx-tool-state { background: var(--warn-soft); color: var(--warn-text); }
.cx-tool-prompt { display: -webkit-box; margin: 0; padding: 0 12px; overflow: hidden; color: var(--text-2); font-size: var(--text-base); line-height: 1.6; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.cx-tool-args { margin: 6px 12px 0; }
.cx-tool-args summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  color: var(--link);
  font-size: var(--text-sm);
  font-weight: 500;
  list-style: none;
}
.cx-tool-args summary::-webkit-details-marker { display: none; }
.cx-tool-args summary .ico { width: 12px; height: 12px; transition: transform var(--dur) ease; }
.cx-tool-args[open] summary .ico { transform: rotate(90deg); }
.cx-tool-json {
  margin: 4px 0 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--code-bg);
  color: var(--text-2);
  font-size: var(--text-sm);
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.cx-tool-out { margin-top: 8px; padding: 0 0 2px; border-top: 1px solid var(--line); }.cx-tool-result { display: flex; align-items: center; gap: 7px; margin: 0; padding: 9px 14px 0; color: var(--ok-text); font-size: var(--text-sm); font-weight: 600; }
.cx-tool-result .ico { width: 16px; height: 16px; }
.cx-tool .cx-shots { padding: 10px 14px 12px; grid-template-columns: repeat(auto-fill, minmax(140px, 180px)); }
.cx-tool-err { margin: 0; padding: 10px 14px; color: var(--err-text); font-size: var(--text-sm); overflow-wrap: anywhere; }
.cx-tool-note { margin: 0; padding: 0 14px 11px; color: var(--faint); font-size: var(--text-xs); overflow-wrap: anywhere; }
.cx-tool-err + .cx-tool-note,
.cx-tool-result + .cx-tool-note { padding-top: 8px; }
.cx-tool-note.is-ok { color: var(--ok-text); }
.cx-tool-note.is-err { color: var(--err-text); }

/* portal → Codex hand-off (tool result) */
.cx-turn.is-note { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.cx-note { display: inline-flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px 8px; max-width: 92%; padding: 2px 10px; border-radius: var(--radius-sm); background: var(--surface-3); color: var(--muted); font-size: var(--text-xs); text-align: center; }
.cx-note .ico { width: 14px; height: 14px; color: var(--accent-text); }
.cx-note-err { margin: 2px 0 0; color: var(--err-text); font-size: var(--text-xs); text-align: center; }

/* images */
.cx-shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-12); align-items: start; }
.cx-shot { margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--bg-deep); }
.cx-shot-img { position: relative; display: block; width: 100%; padding: 0; border: 0; background: var(--surface-3); cursor: zoom-in; }
.cx-shot-img:disabled { cursor: default; }
.cx-shot-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cx-shot-img:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
.cx-shot-gone { position: absolute; inset: 0; display: grid; place-items: center; padding: 8px; color: var(--faint); font-size: var(--text-xs); text-align: center; }
.cx-shot figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 6px 6px 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--text-xs);
}
.cx-shot-no { color: var(--text-2); font-weight: 600; }
.cx-shot-tag { display: inline-flex; align-items: center; gap: 4px; }
.cx-shot-tag .ico { width: 12px; height: 12px; color: var(--accent-text); }
.cx-shot.is-skeleton figcaption { padding-top: 10px; padding-bottom: 10px; }
.cx-shot.is-skeleton .cx-shot-img {
  background: linear-gradient(100deg, var(--surface-3) 30%, var(--surface-2) 50%, var(--surface-3) 70%);
  background-size: 300% 100%;
  cursor: default;
}

/* typing */
.cx-typing { display: flex; align-items: center; gap: 10px; margin: 18px 0 0; color: var(--info-text); font-size: var(--text-sm); }
.cx-dots { display: inline-flex; gap: 4px; }
.cx-dots i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.4; }

/* produced files inside a turn */
.cx-produced { margin-top: 12px; }
.cx-produced-head { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; color: var(--muted); font-size: var(--text-xs); font-weight: 600; }
.cx-produced-head .ico { width: 14px; height: 14px; }
.cx-produced .cx-file-list { max-width: 560px; }

/* file list */
.cx-file-list { margin: 0; padding: 0; overflow: hidden; list-style: none; border: 1px solid var(--line-strong); border-radius: var(--radius-md); background: var(--surface); }
.cx-file { border-top: 1px solid var(--line); }
.cx-file:first-child { border-top: 0; }
.cx-file-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 7px 12px;
  color: var(--text);
  font-size: var(--text-sm);
  transition: background var(--dur-fast) ease, color var(--dur-fast) ease;
}
.cx-file-link:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.cx-file-link .ico { color: var(--muted); }
.cx-file-link:hover .ico { color: var(--accent-text); }
.cx-file-name { flex: 1; min-width: 0; overflow: hidden; font-size: var(--text-sm); white-space: nowrap; text-overflow: ellipsis; }
.cx-file-size { color: var(--muted); font-size: var(--text-xs); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cx-files-note {
  margin: 8px 0 0;
  padding: 10px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--muted);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}
.cx-files-note.is-err { border-color: var(--err-line); color: var(--err-text); }

/* thumbnails */
.cx-thumbs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.cx-thumbs.is-inline { grid-template-columns: repeat(auto-fill, minmax(88px, 112px)); margin-bottom: 8px; }
.cx-thumb {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-3);
  cursor: zoom-in;
}
.cx-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform var(--dur) var(--ease-out); }
.cx-thumb:hover img { transform: scale(1.04); }
.cx-thumb:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.cx-thumb.is-broken img { opacity: 0; }
.cx-thumb.is-broken::after { content: "无法预览"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--faint); font-size: var(--text-xs); }

/* ---- bulk image gallery (P0) ---- */
.wf-gallery-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 10px;
  padding: 0 0 10px;
  border-bottom: 1px solid var(--line);
}
.wf-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.wf-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-md); background: transparent; color: var(--muted); font-size: var(--text-sm); font-weight: 600; cursor: pointer; }
.wf-chip:hover { color: var(--text); border-color: var(--line-strong); }
.wf-chip.is-on { border-color: var(--text); background: var(--surface); color: var(--text); }
.wf-chip .cx-count { margin-left: 2px; opacity: 0.85; font-weight: 500; }
.wf-gallery-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.wf-gallery-actions .btn { font-size: var(--text-xs); }
.wf-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  color: var(--muted);
  font-size: var(--text-xs);
  cursor: pointer;
  user-select: none;
}
.wf-toggle input { margin: 0; }
.wf-gallery-hint {
  margin: 0;
  color: var(--faint);
  font-size: var(--text-xs);
  line-height: 1.4;
}
.wf-more {
  margin: 8px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: var(--text-xs);
}
.cx-thumbs.is-gallery {
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
}
.cx-thumb-wrap {
  position: relative;
  border-radius: var(--radius-md);
}
.cx-thumb-wrap .cx-thumb { width: 100%; }
.cx-thumb-check {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 2;
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--ring);
  cursor: pointer;
}
.cx-thumb-wrap.is-selected .cx-thumb {
  outline: 2px solid var(--ring);
  outline-offset: 1px;
}
.cx-thumb-wrap.is-selected::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius-md);
  box-shadow: inset 0 0 0 999px rgba(28, 79, 176, 0.14);
  pointer-events: none;
}
.cx-viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: rgba(21, 23, 28, 0.72);
  color: #fff;
  font-size: var(--text-2xl);
  line-height: 1;
  cursor: pointer;
}
.cx-viewer-nav:hover { background: #000000; }
.cx-viewer-nav.is-prev { left: 10px; }
.cx-viewer-nav.is-next { right: 10px; }
.cx-viewer-nav[hidden] { display: none !important; }
dialog.cx-viewer { position: relative; }

/* dock + composer (CloudCLI: rounded box, round send button, hint line) */
.cx-dock { position: relative; flex: none; padding: 4px 24px 14px; background: var(--wb-main-bg); }
.cx-jump {
  position: absolute;
  top: -54px;
  right: 28px;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--bubble);
  color: #fff;
  box-shadow: var(--shadow-md);
}
.cx-jump:hover { background: var(--accent-hover); }
.cx-jump .ico { width: 20px; height: 20px; }
.cx-composer { display: flex; flex-direction: column; min-height: 0; overflow: hidden; border: 1px solid var(--field-line); border-radius: var(--radius-lg); background: var(--field); transition: border-color var(--dur-fast) ease; }
.cx-composer:hover { border-color: var(--field-line-hover); }
.cx-composer:focus-within { border-color: var(--ring); outline: 1px solid var(--ring); }
.cx-composer.is-image { border-color: var(--text); }.cx-composer.is-invalid { border-color: var(--err); outline: 1px solid var(--err); }
.cx-composer.is-drop { border-style: dashed; border-color: var(--text); background: var(--surface-3); }
.cx-composer.is-drop::after { content: "松开以附上图片/文件"; display: block; padding: 6px 12px 0; color: var(--text); font-size: var(--text-xs); font-weight: 600; text-align: center; }
.cx-chip-img.is-file {
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--muted);
}
.cx-chip-img.is-file .ico { width: 18px; height: 18px; }
.cx-strip-img.is-file {
  display: grid;
  grid-template-rows: auto auto;
  place-items: center;
  gap: 2px;
  padding: 4px 3px;
  width: auto;
  min-width: 46px;
  max-width: 88px;
  height: auto;
  min-height: 46px;
  cursor: default;
  color: var(--muted);
  background: var(--surface-3);
  border-color: var(--line);
}
.cx-strip-img.is-file .ico { width: 18px; height: 18px; }
.cx-strip-img.is-file .cx-strip-fname {
  display: block;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-xs);
  line-height: 1.2;
  color: var(--muted);
}
.cx-strip.is-small .cx-strip-img.is-file { min-width: 34px; max-width: 72px; min-height: 34px; }
.cx-strip.is-small .cx-strip-img.is-file .cx-strip-fname { max-width: 64px; font-size: var(--text-xs); }
.cx-composer.is-locked { border-style: dashed; background: var(--surface-2); }
.cx-input { display: flex; align-items: flex-end; gap: 8px; padding: 6px 8px 6px 4px; }
.cx-composer textarea.cx-composer-body { flex: 1; display: block; min-height: 52px; max-height: 240px; padding: 10px 12px; border: 0; border-radius: 0; background: transparent; outline: none; resize: none; font-size: var(--text-md); line-height: 1.65; }
.cx-composer textarea.cx-composer-body:focus { outline: none; }
.cx-composer textarea.cx-composer-body:disabled { background: transparent; }
.cx-send { flex: none; display: flex; align-items: center; gap: 6px; padding-bottom: 5px; }
.cx-run, .cx-stop {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
  transition: background var(--dur) ease, color var(--dur) ease, box-shadow var(--dur) ease, transform var(--dur-fast) ease;
}
.cx-run { border: 0; background: var(--accent); color: var(--on-accent); box-shadow: none; }
.cx-run:hover { background: var(--accent-hover); }
.cx-run.is-empty:not(:disabled) { background: var(--surface-3); color: var(--muted); box-shadow: none; }
.cx-run.is-empty:not(:disabled):hover { background: var(--line-strong); color: var(--text); }
.cx-run:active, .cx-stop:active { transform: scale(0.95); }
.cx-run:disabled { background: var(--surface-3); color: var(--faint); box-shadow: none; cursor: not-allowed; transform: none; }
.cx-run .ico, .cx-stop .ico { width: 18px; height: 18px; }
.cx-stop { border: 1px solid var(--err-line); background: var(--err-soft); color: var(--err-text); }
.cx-stop:hover { background: var(--page-cherry); }
.cx-composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 7px 10px 8px 12px;
  border-top: 1px solid var(--line);
}
.cx-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; min-width: 0; }
.cx-chip-btn,
.cx-tool-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 3px 12px 3px 9px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--dur) ease, background var(--dur) ease, color var(--dur) ease;
}
.cx-chip-btn:hover, .cx-tool-toggle:hover { border-color: var(--field-line-hover); background: var(--btn2-bg-hover); color: var(--text); }
.cx-chip-btn[aria-expanded="true"] { border-color: var(--text); background: var(--surface-3); color: var(--text); }
.cx-chip-btn:disabled, .cx-tool-toggle:disabled { opacity: 0.45; cursor: not-allowed; }
.cx-chip-btn[data-fixed="1"] .ico-caret { opacity: 0.35; }
.cx-chip-text { display: inline-flex; align-items: baseline; gap: 4px; min-width: 0; max-width: 14em; }
.cx-chip-model { color: var(--muted); font-size: var(--text-xs); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 9em; }
.cx-effort-btn { padding-left: 10px; }
.cx-effort-k { font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.02em; color: var(--muted); }
.cx-effort-btn[aria-expanded="true"] { border-color: var(--accent-line); }
.wb-menu[data-kind="provider"] { min-width: 260px; max-width: min(360px, 94vw); max-height: min(70vh, 520px); overflow: auto; }
.wb-menu[data-kind="provider"] .wb-menu-desc { font-family: var(--font-mono); font-size: var(--text-xs); }
.cx-chip-logo { display: grid; place-items: center; width: 20px; height: 20px; border-radius: var(--radius-md); background: var(--accent-soft); color: var(--accent-text); }
.cx-chip-logo .ico { width: 13px; height: 13px; }
.cx-chip-btn[data-provider="claude"] .cx-chip-logo { background: var(--page-salmon); color: var(--ink-salmon); }
.cx-tool-toggle[aria-pressed="true"] { border-color: var(--text); background: var(--surface-3); color: var(--text); }
.cx-img-opts { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
label.cx-inline-field { display: inline-flex; align-items: center; gap: 8px; margin: 0; color: var(--muted); font-size: var(--text-sm); font-weight: 500; }
.cx-inline-field select { width: auto; min-width: 0; min-height: 32px; padding: 3px 30px 3px 10px; font-size: var(--text-sm); }
.cx-inline-field input[type=number] { width: 56px; min-height: 32px; padding: 3px 6px; font-size: var(--text-sm); text-align: center; }
.cx-status { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.cx-elapsed { color: var(--muted); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.cx-elapsed:empty { display: none; }
.cx-hint { margin: 8px 0 0; color: var(--faint); font-size: var(--text-xs); text-align: center; }
.btn-ico { display: inline-flex; }
kbd {
  display: inline-block;
  min-width: 1.8em;
  padding: 0 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-md);
  background: var(--surface-3);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.6;
  text-align: center;
}
.cx-field-error { margin: 8px 2px 0; color: var(--err-text); font-size: var(--text-sm); font-weight: 500; }
.wm-chat.is-locked .cx-dock { opacity: 0.6; }

/* status pill + service status (a quiet dot while all is well; a chip only when something is off) */
.cx-gw { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; margin: 0; padding: 0 8px; border-radius: var(--radius-sm); background: var(--page-gray); color: var(--ink-gray); font-size: var(--text-xs); font-weight: 600; line-height: 1.9; white-space: nowrap; }
.cx-gw > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.cx-gw .ico { width: 14px; height: 14px; }
.cx-gw-dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.cx-gw[data-state="ok"],
.cx-gw[data-state="checking"] { background: transparent; color: var(--muted); font-weight: 400; }
.cx-gw[data-state="ok"] .cx-gw-dot { background: var(--ok); }
.cx-gw[data-state="warn"] { background: var(--warn-soft); color: var(--warn-text); }.cx-gw[data-state="err"] { background: var(--err-soft); color: var(--err-text); }.cx-gw[data-state="locked"] { color: var(--muted); }
.cx-pill { display: inline-flex; align-items: center; gap: 5px; padding: 0 6px; border-radius: var(--radius-sm); background: var(--page-gray); color: var(--ink-gray); font-size: var(--text-xs); font-weight: 600; line-height: 1.7; white-space: nowrap; }
.cx-pill::before { content: none; }
.cx-pill:is([data-state="creating"], [data-state="submitting"], [data-state="queued"], [data-state="running"], [data-state="tools"], [data-state="continuing"], [data-state="imaging"])::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.cx-pill:is([data-state="creating"], [data-state="submitting"], [data-state="queued"], [data-state="running"],
  [data-state="tools"], [data-state="continuing"], [data-state="imaging"]) { background: var(--info-soft); color: var(--info-text); }
.cx-pill[data-state="completed"] { background: var(--ok-soft); color: var(--ok-text); }
.cx-pill:is([data-state="failed"], [data-state="error"]) { background: var(--err-soft); color: var(--err-text); }
.cx-pill[data-state="stopped"] { background: var(--warn-soft); color: var(--warn-text); }
.cx-id { display: inline-flex; align-items: baseline; gap: 6px; min-width: 0; }
.cx-id-k { color: var(--faint); }
.cx-id code { color: var(--text-2); font-size: var(--text-xs); }
.cx-meta-idle { display: none; }
.cx-count { padding: 0 6px; border-radius: var(--radius-sm); background: var(--surface-3); color: var(--muted); font-size: var(--text-xs); font-weight: 600; line-height: 1.7; }
.cx-count:empty { display: none; }

/* pending images: ride along with the next message */
.cx-attach { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px 2px; }
.cx-attach-label { display: flex; flex-basis: 100%; align-items: center; gap: 6px; margin: 0; color: var(--muted); font-size: var(--text-xs); }
.cx-attach-label .ico { width: 14px; height: 14px; color: var(--accent-text); }
.cx-attach.is-loading .cx-attach-label,
.cx-attach-label.is-loading { color: var(--accent-text); }
.cx-attach-spin {
  display: inline-block;
  width: 12px; height: 12px;
  margin-left: 4px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent-text);
  border-radius: 50%;
  animation: cxAttachSpin 0.8s linear infinite;
  vertical-align: -1px;
}
@keyframes cxAttachSpin { to { transform: rotate(360deg); } }
.cx-composer.is-attach-loading .cx-run { opacity: 0.7; }

.cx-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--text-xs);
}
.cx-chip-img { flex: none; width: 36px; height: 36px; padding: 0; overflow: hidden; border: 0; border-radius: var(--radius-md); background: var(--surface-3); cursor: zoom-in; }
.cx-chip-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cx-chip-name { min-width: 0; max-width: 16em; overflow: hidden; font-family: var(--font-mono); font-size: var(--text-xs); white-space: nowrap; text-overflow: ellipsis; }
.cx-chip-x {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.cx-chip-x:hover { background: var(--btn2-bg-hover); color: var(--text); }
.cx-chip-x .ico { width: 14px; height: 14px; }

/* examples */
.cx-examples { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; color: var(--muted); font-size: var(--text-sm); }
.cx-example { min-height: 30px; padding: 3px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-md); background: transparent; color: var(--text-2); font: inherit; font-size: var(--text-sm); cursor: pointer; transition: border-color var(--dur) ease, color var(--dur) ease, background var(--dur) ease; }
.cx-example:hover { border-color: var(--text); background: var(--surface-3); color: var(--text); }

/* popover menu (session actions, assistant picker) */
.wb-menu { position: fixed; z-index: 60; min-width: 210px; max-width: min(320px, 92vw); padding: 6px; border: 1px solid var(--line-strong); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-lg); }
.wb-menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 6px 10px; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text); font: inherit; font-size: var(--text-base); text-align: left; }
.wb-menu-item:hover, .wb-menu-item:focus-visible { outline: none; background: var(--wb-hover); }
.wb-menu-item .ico { color: var(--muted); }
.wb-menu-item[aria-checked="true"]::after { content: ""; width: 6px; height: 10px; margin: 0 4px 3px 6px; border: solid var(--text); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.wb-menu-item[aria-disabled="true"] { color: var(--faint); cursor: not-allowed; }
.wb-menu-item[aria-disabled="true"]:hover { background: var(--wb-soft); }
.wb-menu-item.is-danger, .wb-menu-item.is-danger .ico { color: var(--err-text); }
.wb-menu-label { flex: 1; min-width: 0; }
.wb-menu-head { margin: 2px 0; padding: 4px 10px 2px; color: var(--muted); font-size: var(--text-xs); font-weight: 600; }
.wb-menu-item.has-desc { min-height: 48px; padding-top: 7px; padding-bottom: 7px; }
.wb-menu-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.wb-menu-text .wb-menu-label { flex: none; font-weight: 500; }
.wb-menu-desc { color: var(--faint); font-size: var(--text-xs); line-height: 1.4; }
.wb-menu-item[aria-disabled="true"] .wb-menu-desc { color: var(--warn-text); opacity: 0.85; }
.wb-menu-note { flex: none; color: var(--faint); font-size: var(--text-xs); }
.wb-menu-note.is-off { color: var(--warn-text); font-family: var(--font-body); font-weight: 600; }
.wb-menu-sep { height: 1px; margin: 4px 6px; background: var(--line); }

/* image viewer */
dialog.cx-viewer {
  width: fit-content;
  min-width: min(360px, 94vw);
  max-width: min(94vw, 980px);
  max-height: 94vh;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xl);
}
dialog.cx-viewer::backdrop, dialog.wb-dialog::backdrop { background: var(--scrim); }
.cx-viewer-img { display: block; max-width: min(94vw, 980px); max-height: calc(94vh - 58px); margin: 0 auto; object-fit: contain; background: var(--text); }
.cx-viewer-bar { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 14px; border-top: 1px solid var(--line); }
.cx-viewer-cap { flex: 1; min-width: 0; overflow: hidden; color: var(--muted); font-size: var(--text-sm); white-space: nowrap; text-overflow: ellipsis; }

/* legacy webhook — kept, moved into a dialog off the sidebar */
dialog.wb-dialog[open] {
  display: block;
  z-index: 100;
}
dialog.wb-dialog { width: min(560px, 94vw); max-height: 92vh; padding: 0; border: 1px solid var(--line-strong); border-radius: var(--radius-xl); background: var(--surface); color: var(--text); box-shadow: var(--shadow-xl); }
.wb-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 10px 6px 20px; }
.wb-dialog-head h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: var(--text-lg); font-weight: 700; }
.wb-dialog-note { margin: 0 20px; color: var(--text); font-size: var(--text-base); font-weight: 600; }
.wb-dialog-note:empty { display: none; }
.cx-legacy-state:empty { display: none; }
.cx-legacy-state { padding: 0 8px; border-radius: var(--radius-sm); background: var(--surface-3); color: var(--muted); font-size: var(--text-xs); font-weight: 600; }
.cx-legacy-state[data-ok="1"] { background: var(--ok-soft); color: var(--ok-text); }
.cx-legacy-form { margin: 0; padding: 8px 20px 20px; }
.cx-legacy-form textarea { font-size: var(--text-md); }
.cx-legacy-actions { margin-top: var(--space-12); }

/* 9 · responsive -------------------------------------------------------- */
@media (min-width: 900px) {
  /* collapsed sessions pane: an icon rail */
  .wb[data-left="collapsed"] { --wb-side-w: 64px; }
  .wb[data-left="collapsed"] .wb-side > :not(.ws-rail) { display: none; }
  .wb[data-left="collapsed"] .ws-rail { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 0; }
  .ws-rail-new { background: var(--accent); color: var(--on-accent); }
  .ws-rail-run { min-width: 22px; padding: 0 6px; border-radius: var(--radius-sm); background: var(--info-soft); color: var(--info-text);  font-size: var(--text-xs); font-weight: 700; line-height: 20px; text-align: center; }
}
@media (max-width: 1439px) {
  .wb { --wb-side-w: 264px; --wb-files-w: 296px; }
  .wm-head .cx-gw { max-width: 190px; }
}
@media (max-width: 1279px) {
  .wm-head .cx-gw .cx-gw-text { display: none; }
  .wm-head .cx-gw { padding: 0 6px; }
  .wm-tab .wb-live { display: none; }
}
@media (max-width: 1179px) {
  .wb { --wb-files-w: 0px; }
  .wb-files {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    width: min(360px, 92vw);
    visibility: hidden;
    box-shadow: var(--shadow-xl);
    transform: translateX(102%);
    transition: transform var(--dur-slow) var(--ease-out), visibility 0s linear var(--dur-slow);
  }
  .wb.files-open .wb-files { visibility: visible; transform: none; transition: transform var(--dur-slow) var(--ease-out), visibility 0s; }
  .wb-files { grid-column: auto; grid-row: auto; }   /* positioned against the whole workbench */
  .wb[data-right="collapsed"][data-tab="chat"] .wb-files { display: flex; }
  .wb[data-tab="chat"] .wm-files-btn { display: inline-grid; }
}
@media (max-width: 899px) {
  .wb, .wb[data-left="collapsed"] { --wb-side-w: 0px; grid-template-columns: minmax(0, 1fr); }
  .wb-main { grid-column: 1; }
  .wb-side { grid-column: auto; grid-row: auto; }
  .wb-side {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    width: min(320px, 88vw);
    visibility: hidden;
    box-shadow: var(--shadow-xl);
    transform: translateX(-102%);
    transition: transform var(--dur-slow) var(--ease-out), visibility 0s linear var(--dur-slow);
  }
  .wb.side-open .wb-side { visibility: visible; transform: none; transition: transform var(--dur-slow) var(--ease-out), visibility 0s; }
  .wm-menu { display: inline-grid; }
  .ws-close { display: inline-grid; }
  .ws-collapse { display: none; }
  .wm-head { padding-left: 12px; }
}
/* forms + jobs table stack by the width of the view itself (the side panes take room),
   with the old viewport breakpoint as the fallback */
.wm-doc { container-type: inline-size; container-name: wmdoc; }
@container wmdoc (max-width: 960px) {
  .job-grid { grid-template-columns: 1fr; }
  .job-links textarea { min-height: 180px; }
  .job-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--space-md); }
  .job-meta .field:first-child { grid-column: 1 / -1; }
  .job-meta .field:first-child label { margin-top: var(--space-md); }
  .delivery-grid { grid-template-columns: 1fr; }

  /* jobs table → stacked cards */
  .jobs-scroll { overflow: visible; }
  .jobs-table, .jobs-table tbody, .jobs-table tr, .jobs-table td { display: block; width: 100%; }
  .jobs-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .jobs-table tr {
    margin-bottom: 10px;
    padding: 6px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface-2);
  }
  .jobs-table tr:last-child { margin-bottom: 0; }
  .jobs-table tbody tr:hover > td,
  .job-failed > td { background: transparent; }
  .jobs-table td {
    position: relative;
    padding: 8px 0 8px 80px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: normal;
  }
  .jobs-table td:last-child { border-bottom: 0; }
  .jobs-table td::before {
    content: attr(data-label);
    position: absolute;
    top: 9px;
    left: 0;
    width: 72px;
    color: var(--faint);
    font-family: var(--font-body);
    font-size: var(--text-xs);
    font-weight: 500;
  }
  .jobs-table .col-id, .jobs-table .col-act { width: 100%; text-align: left; }
  .jobs-table td.col-act-empty { display: none; }
  /* lead each card with the title, then status */
  .jobs-table tr { display: flex; flex-direction: column; }
  .jobs-table td.job-title { order: -2; padding: 8px 0 6px; border-bottom: 0; font-size: var(--text-base); }
  .jobs-table td.job-title::before { content: none; }
  .jobs-table td.job-status { order: -1; }
  .job-baidu { max-width: none; }
  .job-error { max-width: none; }
  .job-title { min-width: 0; }
}
@supports not (container-type: inline-size) {
@media (max-width: 900px) {
  .job-grid { grid-template-columns: 1fr; }
  .job-links textarea { min-height: 180px; }
  .job-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--space-md); }
  .job-meta .field:first-child { grid-column: 1 / -1; }
  .job-meta .field:first-child label { margin-top: var(--space-md); }
  .delivery-grid { grid-template-columns: 1fr; }

  /* jobs table → stacked cards */
  .jobs-scroll { overflow: visible; }
  .jobs-table, .jobs-table tbody, .jobs-table tr, .jobs-table td { display: block; width: 100%; }
  .jobs-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .jobs-table tr {
    margin-bottom: 10px;
    padding: 6px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface-2);
  }
  .jobs-table tr:last-child { margin-bottom: 0; }
  .jobs-table tbody tr:hover > td,
  .job-failed > td { background: transparent; }
  .jobs-table td {
    position: relative;
    padding: 8px 0 8px 80px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: normal;
  }
  .jobs-table td:last-child { border-bottom: 0; }
  .jobs-table td::before {
    content: attr(data-label);
    position: absolute;
    top: 9px;
    left: 0;
    width: 72px;
    color: var(--faint);
    font-family: var(--font-body);
    font-size: var(--text-xs);
    font-weight: 500;
  }
  .jobs-table .col-id, .jobs-table .col-act { width: 100%; text-align: left; }
  .jobs-table td.col-act-empty { display: none; }
  /* lead each card with the title, then status */
  .jobs-table tr { display: flex; flex-direction: column; }
  .jobs-table td.job-title { order: -2; padding: 8px 0 6px; border-bottom: 0; font-size: var(--text-base); }
  .jobs-table td.job-title::before { content: none; }
  .jobs-table td.job-status { order: -1; }
  .job-baidu { max-width: none; }
  .job-error { max-width: none; }
  .job-title { min-width: 0; }
}
}
/* between a full desktop and the phone layout: tighter sections, the account shown by its initial alone */
@media (min-width: 769px) and (max-width: 1023px) {
  .top-nav a { padding: 0 8px; }
  .top-nav a.nav-g { margin-left: 13px; }
  .top-nav a.nav-g::before { left: -7px; }
  .acct-name { display: none; }
}
@media (max-width: 768px) {
  :root { --gutter: 16px; }
  html { scroll-padding-top: 16px; }
  .wrap { padding: var(--space-md) var(--gutter) var(--space-2xl); }
  .card { padding: var(--space-md); }
  .grid2 { grid-template-columns: 1fr; }
  /* top bar on phones: brand and account on one row, the sections on a second row that scrolls sideways */
  header.top { position: static; }
  header.top .inner { flex-wrap: wrap; gap: 0; }
  .brand, .top-end { min-height: 44px; }
  .top-nav {
    order: 3;
    flex: 1 0 100%;
    min-height: 40px;
    margin: 0 calc(-1 * var(--gutter));
    padding: 0 calc(var(--gutter) - 10px);
    border-top: 1px solid var(--line);
  }
  body.admin-host .top-nav { border-top-color: var(--rule-goldenrod); }
  .top-nav a { padding: 0 10px; }
  .acct-name { max-width: 9em; }
  /* 16px fields: phones zoom the page when a smaller field takes focus */
  input[type=text], input[type=email], input[type=password], input[type=search],
  input[type=number], input[type=url], input[type=date], textarea, select { min-height: 40px; font-size: var(--text-lg); }
  .btn { min-height: 40px; }
  .btn.sm { min-height: 32px; }
  .page-head { align-items: flex-start; }
  .page-jump { flex-wrap: nowrap; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .field-row { flex-wrap: wrap; }
  .share-acts { margin-left: 0; }
  .auth { grid-template-columns: minmax(0, 1fr); gap: var(--space-lg); min-height: 0; padding-top: 0; }
  .auth-card { padding: 20px; }
  .pages { max-width: 180px; justify-self: center; }
  .job-meta { grid-template-columns: 1fr; }
  .delivery-opts { grid-template-columns: 1fr; }
  .form-actions { flex-direction: column-reverse; align-items: stretch; }
  .form-actions .btn { width: 100%; }
  .notice { padding: var(--space-md); }
  /* workbench on phones: the site links move into the sessions drawer, a bottom bar switches views */
  body.page-app header.top { display: none; }
  body.page-app .flash { margin: 8px 10px; }
  .ws-site { display: flex; }
  .ws-user { display: flex; }
  .ws-links { flex-direction: column; flex-wrap: nowrap; }
  .ws-link { width: 100%; min-height: 40px; }
  .wm-head { gap: 8px; padding: 0 10px; }
  .wm-tabs { display: none; }
  input.wm-title-input, .wm-title-text { font-size: var(--text-lg); }
  .wm-sub .cx-id:not(:first-of-type) { display: none; }
  .wb-bottom { display: grid; }
  .wb-files { width: 100%; }
  .wb-side { width: min(320px, 90vw); }
  .wm-doc { padding: 2px 12px 24px; }
  .wm-doc > .card { margin-top: 12px; }

  .cx-thread { padding: 16px 12px 12px; }
  .cx-dock { padding: 2px 10px 10px; }
  .cx-jump { top: -50px; right: 16px; width: 40px; height: 40px; }
  .cx-hint { display: none; }
  .cx-intro-title { font-size: var(--text-xl); }
  .cx-user-col { max-width: 86%; }
  .cx-bubble { font-size: var(--text-md); }
  .cx-uavatar { width: 28px; height: 28px; font-size: var(--text-xs); }
  .cx-turn.is-user, .cx-turn-user { gap: 8px; }
  .cx-avatar { width: 30px; height: 30px; }
  .cx-avatar .ico { width: 15px; height: 15px; }
  .cx-tool-row { grid-template-columns: 30px minmax(0, 1fr); gap: 0 8px; }
  .cx-md { font-size: var(--text-md); }
  .cx-tool .cx-shots, .cx-shots { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .cx-tool .cx-shots { padding: 10px; }
  .cx-composer-foot { padding: 6px 8px 7px; }
  .cx-img-opts { flex: 1 1 100%; }
  .cx-inline-field select { flex: 1; }
  label.cx-inline-field:first-child { flex: 1; }
  .cx-chip-name { max-width: 9em; }
  .cx-shot figcaption { padding: 4px 4px 4px 8px; }
  .cx-shot figcaption .btn { min-height: 32px; padding: 4px 8px; }
  .cx-shot figcaption .btn-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
}
@media (max-width: 380px) {
  .cx-status .cx-elapsed { display: none; }
  .cx-chip-btn, .cx-tool-toggle { padding: 3px 10px 3px 8px; }
}

/* 10 · motion (subtle; disabled for reduced motion) ---------------------- */
@keyframes cxPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
@keyframes cxDot {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}
@keyframes cxShimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}
@keyframes cxReveal {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes cxSpin { to { transform: rotate(360deg); } }
@keyframes cxBar {
  0% { background-position: -60% 0; }
  100% { background-position: 160% 0; }
}
.cx-gw[data-state="checking"] .cx-gw-dot,
.cx-pill:is([data-state="running"], [data-state="queued"], [data-state="creating"], [data-state="submitting"],
  [data-state="tools"], [data-state="continuing"], [data-state="imaging"])::before,
.ws-row[data-state="busy"] .ws-state::before,
.badge.processing.dot::before { animation: cxPulse 1.4s ease-in-out infinite; }
.ws-row[data-state="busy"] .ws-ico .ico { animation: cxSpin 1s linear infinite; }
.cx-window:is([data-state="creating"], [data-state="submitting"], [data-state="queued"], [data-state="running"],
  [data-state="tools"], [data-state="continuing"], [data-state="imaging"])::before { animation: cxBar 1.6s ease-in-out infinite; }
.cx-dots i { animation: cxDot 1.2s ease-in-out infinite; }
.cx-dots i:nth-child(2) { animation-delay: 0.15s; }
.cx-dots i:nth-child(3) { animation-delay: 0.3s; }
.cx-shot.is-skeleton .cx-shot-img { animation: cxShimmer 1.5s linear infinite; }
.cx-turn.is-new, .cx-shot.is-fresh { animation: cxReveal var(--dur-slow) var(--ease-out) both; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}


/* 11 · admin skills dialog (v16) ------------------------------------------
   Toolbar + status bar stay put; the add / edit form and the list scroll under them.
   A row = name · slug · 启用 switch / 说明 / Codex · Claude switches · 编辑 · 删除.
   The left rail of a row is green while the skill is on. */
dialog.wb-skills-dialog {
  width: min(760px, 96vw);
  max-height: min(88vh, 920px);
  overflow: hidden;
}
dialog.wb-skills-dialog[open] { display: flex; flex-direction: column; }
.wb-skills-dialog .wb-dialog-head { flex: none; }
.wb-skills-dialog .wb-dialog-note { flex: none; margin: 2px 18px 0; max-width: 62em; }
.wb-skills-dialog .wb-dialog-note strong { color: var(--text); font-weight: 600; }

.sk-bar { display: flex; flex: none; flex-wrap: wrap; align-items: center; gap: 8px; padding: 14px 18px 12px; }
.sk-sum { margin-left: auto; color: var(--muted); font-size: var(--text-sm); white-space: nowrap; }

.sk-status {
  flex: none;
  margin: 0 18px 12px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--wb-soft, transparent);
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.55;
}
.sk-status[data-kind="ok"] { border-color: var(--ok-line); background: var(--ok-soft); color: var(--ok-text); }
.sk-status[data-kind="err"] { border-color: var(--err-line); background: var(--err-soft); color: var(--err-text); }
.sk-status-line { display: flex; align-items: flex-start; gap: 8px; margin: 0; font-weight: 500; }
.sk-status-line .ico { flex: none; width: 16px; height: 16px; margin-top: 2px; }
.sk-status[data-kind="busy"] .sk-status-line .ico { animation: cxSpin 0.9s linear infinite; }
.sk-status-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 6px 0 0 24px; }
.sk-status-why { flex: 1 1 260px; color: var(--text-2); font-weight: 400; }
.sk-status-hint .btn { min-height: 28px; padding: 2px 10px; font-size: var(--text-sm); }

.sk-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 0 18px 18px; }

/* list */
.sk-list { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--wb-side-bg, var(--bg-deep)); }
.sk-loading { margin: 0; padding: 22px 16px; color: var(--muted); font-size: var(--text-sm); text-align: center; }
.sk-row { position: relative; padding: 12px 14px 12px 18px; outline: none; transition: background var(--dur) ease; }
.sk-row + .sk-row { border-top: 1px solid var(--line); }
.sk-row::before {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 0;
  width: 3px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--line-strong);
}
.sk-row[data-on="1"]::before { background: var(--accent); }
.sk-row:hover { background: var(--wb-hover, var(--row-hover)); }
.sk-row:focus-visible { box-shadow: inset 0 0 0 2px var(--ring); }
.sk-row:first-child { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.sk-row:last-child { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.sk-row:only-child { border-radius: var(--radius-lg); }
.sk-row.is-flash { animation: skFlash 2.2s linear 1; }
@keyframes skFlash {
  0%, 40% { background: var(--accent-soft); }
  100% { background: transparent; }
}
.sk-row-head { display: flex; align-items: center; gap: 12px; }
.sk-row-id { display: flex; flex: 1; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; min-width: 0; }
.sk-row-name { color: var(--text); font-size: var(--text-md); font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.sk-row[data-on="0"] .sk-row-name { color: var(--text-2); }
.sk-row-slug { color: var(--faint); font-size: var(--text-xs); overflow-wrap: anywhere; }
.sk-row-desc {
  display: -webkit-box;
  margin: 3px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.55;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.sk-row-desc.is-empty { color: var(--faint); }
.sk-row-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 10px; }
.sk-row-provs { display: flex; flex-wrap: wrap; gap: 6px; }
.sk-row[data-on="0"] .sk-row-provs { opacity: 0.6; }
.sk-row-time { color: var(--faint); font-size: var(--text-xs); white-space: nowrap; }
.sk-row-time:empty { display: none; }
.sk-row-acts { display: flex; gap: 2px; margin-left: auto; }
.sk-row-acts .btn { min-height: 30px; padding: 3px 9px; }
.sk-row-acts .btn.is-danger:hover { background: var(--err-soft); color: var(--err-text); }
.sk-row[aria-busy="true"] .sk-switch { cursor: progress; opacity: 0.7; }

/* switches (checkbox + role="switch"; the track is drawn, the input stays focusable) */
label.sk-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 4px 11px 4px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.35;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: border-color var(--dur-fast) ease, color var(--dur-fast) ease;
}
.sk-switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: inherit;
}
.sk-track {
  position: relative;
  flex: none;
  width: 28px;
  height: 16px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  transition: background var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}
.sk-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform var(--dur-fast) var(--ease-out), background var(--dur-fast) ease;
}
.sk-switch input:checked + .sk-track { background: var(--accent); box-shadow: none; }
.sk-switch input:checked + .sk-track::after { background: #ffffff; transform: translateX(12px); }
.sk-switch input:focus-visible + .sk-track { outline: 2px solid var(--ring); outline-offset: 2px; }
.sk-switch:hover { border-color: var(--field-line-hover); color: var(--text-2); }
.sk-switch:has(input:checked) { border-color: var(--accent-line); color: var(--text); }
label.sk-switch.sk-switch-main { padding-right: 4px; border-color: transparent; }
label.sk-switch.sk-switch-main:has(input:checked) { color: var(--accent-text); }
.sk-switch-main .sk-switch-text { min-width: 3em; }

/* add / edit form */
.sk-form { margin: 0 0 14px; padding: 14px 16px 16px; border: 1px solid var(--accent-line); border-radius: var(--radius-lg); background: var(--surface-2); }
.sk-form-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.sk-form-title { margin: 0; color: var(--text); font-family: var(--font-body); font-size: var(--text-md); font-weight: 600; }
.sk-form-sub { color: var(--muted); font-size: var(--text-sm); }
.sk-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 14px; }
.sk-field { min-width: 0; }
.sk-form label[for] { display: flex; align-items: center; gap: 6px; margin: 12px 0 5px; font-size: var(--text-sm); }
.sk-form input[type=text] { padding: 8px 11px; font-size: var(--text-base); }
.sk-form input[type=text]#sk-slug { font-family: var(--font-mono); font-size: var(--text-sm); }
.sk-form input[readonly] { border-color: var(--line); background: var(--surface-3); color: var(--muted); cursor: default; }
.sk-form textarea { min-height: 190px; font-size: var(--text-sm); line-height: 1.65; }
.sk-form [aria-invalid="true"] { border-color: var(--err); box-shadow: 0 0 0 3px var(--err-soft); }
.sk-form label.sk-switch:has(input[aria-invalid="true"]) { border-color: var(--err); color: var(--err-text); }
.sk-auto { padding: 0 7px; border-radius: var(--radius-sm); background: var(--info-soft); color: var(--info-text); font-size: var(--text-xs); font-weight: 600; line-height: 1.6; }
.sk-help { margin: 5px 0 0; color: var(--faint); font-size: var(--text-xs); line-height: 1.5; }
.sk-form-switches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.sk-form-switches label.sk-switch { background: var(--field); }
.sk-form-err { margin: 12px 0 0; color: var(--err-text); font-size: var(--text-sm); font-weight: 500; }
.sk-form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.sk-form-actions .btn[aria-disabled="true"] { opacity: 0.6; cursor: progress; }
.sk-kbd { margin-left: auto; color: var(--faint); font-size: var(--text-xs); }

/* empty / failed list */
.sk-empty { padding: 28px 18px 26px; text-align: center; }
.sk-empty-title { margin: 0; color: var(--text); font-size: var(--text-base); font-weight: 600; }
.sk-empty-text { max-width: 30em; margin: 4px auto 0; color: var(--muted); font-size: var(--text-sm); }
.sk-empty .btn { margin-top: 12px; }

@media (max-width: 768px) {
  .sk-form input[type=text], .sk-form input[type=text]#sk-slug, .sk-form textarea { font-size: var(--text-lg); }
  .sk-kbd { display: none; }
}
@media (max-width: 560px) {
  dialog.wb-skills-dialog { width: 96vw; max-height: 92dvh; }
  .wb-skills-dialog .wb-dialog-note { margin: 2px 14px 0; }
  .sk-bar { padding: 12px 14px 10px; }
  .sk-sum { flex-basis: 100%; order: 9; margin-left: 2px; }
  .sk-status { margin: 0 14px 10px; }
  .sk-status-hint { margin-left: 0; }
  .sk-scroll { padding: 0 12px 14px; }
  .sk-grid { grid-template-columns: minmax(0, 1fr); }
  .sk-row { padding: 12px 10px 12px 14px; }
  .sk-row-head { align-items: flex-start; }
  .sk-row-acts { margin-left: auto; }
}


/* 12 · image previews (v17) -----------------------------------------------
   Thumbs come from the CDN only. Until the CDN copy exists a tile is a shimmering placeholder with
   「生成中…」 (「暂无预览」 once the lookups stop); a thumb that can't load leaves a grey tile. */
.cx-wait {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 6px;
  color: var(--faint);
  font-size: var(--text-xs);
  line-height: 1.3;
  text-align: center;
  pointer-events: none;
}
:is(.cx-thumb, .cx-md-img, .cx-shot-img, .cx-strip-img, .cx-chip-img).is-wait {
  position: relative;
  background: linear-gradient(100deg, var(--surface-3) 30%, var(--surface-2) 50%, var(--surface-3) 70%);
  background-size: 300% 100%;
  animation: cxShimmer 1.5s linear infinite;
  cursor: pointer;
}
.cx-md-img.is-wait { width: 168px; max-width: 100%; aspect-ratio: 4 / 3; }
.cx-shot-img.is-wait { min-height: 96px; }
:is(.cx-strip-img, .cx-chip-img).is-wait .cx-wait { font-size: 0; }   /* too small for words: the shimmer says it */
/* a thumb that can't load: grey tile (the original never loads in its place) */
:is(.cx-md-img, .cx-shot-img, .cx-strip-img, .cx-chip-img) { position: relative; }
:is(.cx-md-img, .cx-shot-img, .cx-strip-img, .cx-chip-img).is-broken img { opacity: 0; }
.cx-md-img.is-broken { min-width: 120px; min-height: 90px; }
:is(.cx-md-img, .cx-shot-img).is-broken::after {
  content: "无法预览";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--faint);
  font-size: var(--text-xs);
}
/* viewer: no CDN original yet (or it didn't load) — say so; 下载 stays */
.cx-viewer-wait {
  margin: 0;
  padding: 56px 28px;
  min-width: min(380px, 94vw);
  max-width: min(94vw, 560px);
  color: var(--muted);
  font-size: var(--text-base);
  line-height: 1.6;
  text-align: center;
}


/* 13 · run outcome (v18) ---------------------------------------------------
   A run that didn't end as "completed" but left pictures behind counts as done: instead of the red alert the
   turn gets this quiet grey line (how the run ended, technical status in small print underneath). */
.cx-agent-soft {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 10px 0 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.6;
}
.cx-agent-soft .ico { flex: none; width: 15px; height: 15px; margin-top: 3px; color: var(--faint); }
.cx-agent-soft-body { min-width: 0; }
.cx-agent-soft-text { margin: 0; }
.cx-agent-soft-why { margin: 1px 0 0; color: var(--faint); font-size: var(--text-xs); overflow-wrap: anywhere; }

.btn-sm{padding:4px 10px;font-size: var(--text-xs);border-radius: var(--radius-lg);line-height:1.3}
/* UX: hide batch progress card (skill-driven single-task gen) */
#codex-batch-card,.cx-batch-card{display:none!important}
/* === P3 codex batch progress === */
.cx-batch-card{margin:10px 12px;padding:10px 12px;border:1px solid var(--border);border-radius: var(--radius-lg);background:var(--surface-2)}
.cx-batch-card[hidden]{display:none!important}
.cx-batch-title{display:flex;align-items:center;gap:6px;font-size: var(--text-sm);font-weight:600;margin:0 0 6px}
.cx-batch-meta{font-size: var(--text-xs);color:var(--muted);margin:0 0 8px;word-break:break-all}
.cx-batch-bar{height:8px;border-radius: var(--radius-sm);background:var(--bg-deep);overflow:hidden}
.cx-batch-bar > i{display:block;height:100%;width:0;background:var(--text);transition:width .3s ease}
.cx-batch-actions{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}
.cx-batch-actions button{font-size: var(--text-xs)}

/* Backend Evo fill card (portal → gateway; not sandbox) */
.cx-evo-card{margin:10px 12px;padding:10px 12px;border:1px solid var(--border);border-radius: var(--radius-lg);background:var(--surface-2)}
.cx-evo-card[hidden]{display:none!important}
.cx-evo-title{display:flex;align-items:center;gap:6px;font-size: var(--text-sm);font-weight:600;margin:0 0 6px}
.cx-evo-meta{font-size: var(--text-xs);color:var(--muted);margin:0 0 8px;word-break:break-all}
.cx-evo-bar{height:8px;border-radius: var(--radius-sm);background:var(--bg-deep);overflow:hidden}
.cx-evo-bar > i{display:block;height:100%;width:0;background:var(--text);transition:width .3s ease}
.cx-evo-actions{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}
.cx-evo-actions button{font-size: var(--text-xs)}



/* skill stream: thinking + step progress */
.cx-agent-thinking {
  margin: 0 0 10px;
  padding: 8px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.55;
}
.cx-agent-thinking-sum {
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
  list-style: none;
}
.cx-agent-thinking-sum::-webkit-details-marker { display: none; }
.cx-agent-thinking-body {
  margin: 8px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: var(--text-sm);
  color: var(--faint);
  max-height: 220px;
  overflow: auto;
}
.cx-agent-progress {
  margin: 0 0 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.5;
}
.cx-agent-progress-title {
  font-weight: 600;
  color: var(--text);
  margin: 0 0 4px;
  font-size: var(--text-sm);
}
.cx-agent-progress-hint {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: var(--text-xs);
}
.cx-agent-steps {
  margin: 0;
  padding-left: 18px;
}
.cx-agent-step {
  margin: 2px 0;
}
.cx-agent-step-tool {
  font-weight: 600;
  font-family: var(--font-mono, ui-monospace, monospace);
  color: var(--text);
}
.cx-agent-step-preview {
  color: var(--faint);
  word-break: break-word;
}


/* Upstream interactive prompt relay (phase 1 — display + answer stub) */
.cx-prompt-card {
  margin: 10px 0 12px;
  padding: 12px 14px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--rule-yellow);
  background: var(--page-yellow);
  color: var(--text);
}
.cx-prompt-card.is-answered {
  border-color: var(--rule-green);
  background: var(--page-green);
}
.cx-prompt-card-kicker {
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-yellow);
  margin-bottom: 4px;
}
.cx-prompt-card-title {
  font-weight: 600;
  font-size: var(--text-base);
  margin-bottom: 6px;
}
.cx-prompt-card-q {
  font-size: var(--text-sm);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 10px;
  opacity: 0.95;
}
.cx-prompt-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.cx-prompt-btn {
  appearance: none;
  border: 1px solid var(--field-line);
  background: var(--surface);
  color: inherit;
  border-radius: var(--radius-md);
  padding: 6px 14px;
  font-size: var(--text-sm);
  cursor: pointer;
}
.cx-prompt-btn:hover {
  border-color: var(--text);
  background: var(--surface-3);
}
.cx-prompt-card-hint,
.cx-prompt-card-note {
  font-size: var(--text-xs);
  opacity: 0.7;
  line-height: 1.4;
}

