/* assets/css/tokens.css */
/* ============================================================
   BOXORDER 0100 — Design tokens (single source of truth)
   Style: enterprise calm. Cool grey-blue neutrals, one accent,
   dense spacing, quiet surfaces, no decoration beyond hairline.
   Change `data-style` on <html> to re-skin: calm | warm | graphite
   ============================================================ */

/* ---------- 1. Raw scale ---------- */
:root {
  color-scheme: light;

  /* Neutral ramp — cool, slightly blue */
  --n-0: #ffffff;
  --n-25: #fbfcfd;
  --n-50: #f6f8fa;
  --n-100: #f1f4f7;
  --n-150: #e9edf2;
  --n-200: #dfe5ec;
  --n-300: #cbd4de;
  --n-400: #9ba7b5;
  --n-500: #77828f;
  --n-600: #5d6977;
  --n-700: #46525f;
  --n-800: #2b3542;
  --n-900: #17202b;

  /* Single accent — calm cobalt */
  --a-50: #eef3fd;
  --a-100: #dde8fb;
  --a-200: #c6d7f5;
  --a-400: #5c85e0;
  --a-500: #2b5fd6;
  --a-600: #1f4fbe;
  --a-700: #173d96;

  /* Semantic hues (used sparingly) */
  --ok-50: #e8f3ef;
  --ok-500: #17775a;
  --warn-50: #fbf2e3;
  --warn-500: #9a640d;
  --danger-50: #fbeeec;
  --danger-500: #b23a30;
  --ai-50: #e7f3f4;
  --ai-500: #0f6f78;

  /* Rail (graphite, not black) */
  --rail-1: #19212b;
  --rail-2: #121922;
  --rail-text: #e6ecf4;
  --rail-muted: #8c97a5;
  --rail-line: #232d39;
}

/* ---------- 2. Semantic aliases ---------- */
:root {
  --bg: var(--n-100);
  --paper: var(--bg);
  --surface: var(--n-0);
  --surface-2: var(--n-50);
  --surface-3: var(--n-150);
  --line: var(--n-200);
  --line-strong: var(--n-300);

  --text: var(--n-900);
  --text-2: var(--n-700);
  --muted: var(--n-500);
  --faint: var(--n-400);
  --ink: var(--n-900);

  --brand: var(--a-500);
  --brand-ink: var(--a-600);
  --brand-soft: var(--a-50);
  --brand-line: var(--a-200);
  --info: var(--a-500);
  --info-soft: var(--a-50);

  --teal: var(--ai-500);
  --teal-soft: var(--ai-50);
  --ai: var(--ai-500);
  --ai-soft: var(--ai-50);

  --ok: var(--ok-500);
  --ok-soft: var(--ok-50);
  --warn: var(--warn-500);
  --warn-soft: var(--warn-50);
  --danger: var(--danger-500);
  --danger-soft: var(--danger-50);
}

/* ---------- 3. Space, shape, depth ---------- */
:root {
  /* 4 / 8 rhythm */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  --r-1: 4px;
  --r-2: 6px;
  --r-3: 8px;
  --r-4: 10px;
  --r-5: 12px;
  --r-6: 16px;
  --r-pill: 999px;

  /* Legacy radius names */
  --r-xs: var(--r-1);
  --r-sm: var(--r-2);
  --r-md: var(--r-3);
  --r-lg: var(--r-5);
  --r-xl: var(--r-6);

  --shadow-1: 0 1px 2px rgba(20, 31, 46, 0.05);
  --shadow-2: 0 2px 8px rgba(20, 31, 46, 0.06), 0 1px 2px rgba(20, 31, 46, 0.04);
  --shadow-3: 0 16px 40px rgba(16, 26, 40, 0.14), 0 2px 8px rgba(16, 26, 40, 0.06);
  --shadow-rail: inset -1px 0 0 rgba(255, 255, 255, 0.04);

  /* Control metrics */
  --control-h: 30px;
  --control-h-sm: 26px;
  --control-h-lg: 34px;
  --icon-1: 14px;
  --icon-2: 16px;
  --icon-3: 18px;
  --icon-4: 20px;

  /* Layout */
  --rail-w: 236px;
  --rail-w-collapsed: 60px;
  --topbar-h: 52px;
  --inspector-w: 352px;
  --composer-h: 76px;
}

/* ---------- 4. Type ---------- */
:root {
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
          -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  --fs-2xs: 10px;
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-md: 13px;
  --fs-lg: 14px;
  --fs-xl: 16px;
  --fs-2xl: 20px;
  --fs-3xl: 26px;
  --fs-4xl: 32px;

  /* Poster-specific type & box */
  --poster-title: 30px;
  --poster-body: 18px;
  --poster-num: 22px;
  --poster-qr: 107px;
  --poster-w: 480px;
  --poster-h: 640px;

  /* Legacy names */
  --fs-micro: var(--fs-2xs);
  --fs-base: var(--fs-md);
  --lh: 1.5;
  --lh-tight: 1.25;
  --lh-snug: 1.4;

  --tracking-label: 0.11em;
  --tracking-tight: -0.01em;
  --tracking-display: -0.025em;
}

/* ---------- 5. Motion ---------- */
:root {
  --dur-1: 120ms;
  --dur-2: 160ms;
  --dur-3: 200ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
}

/* ---------- 6. Poster / storefront surfaces (still tokenised) ---------- */
:root {
  --poster-bg: #fbfcfe;
  --poster-ink: #16202b;
  --poster-muted: #5f6c79;
  --poster-line: #e1e7ee;
  --poster-soft: #f3f6f9;
  --sf-bg: #fbfcfd;
  --sf-ink: #1a2430;
  --sf-muted: #5f6c79;
  --sf-line: #e3e9f0;
  --sf-card: #ffffff;
}

/* ---------- 7. Dark theme ---------- */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e141b;
  --paper: var(--bg);
  --surface: #161d26;
  --surface-2: #1b242f;
  --surface-3: #222c38;
  --line: #28323e;
  --line-strong: #3a4553;

  --text: #e9eef5;
  --text-2: #c1cad5;
  --muted: #8b96a4;
  --faint: #6c7785;

  --brand-soft: #16233c;
  --brand-line: #2b3f66;
  --ok-soft: #122a22;
  --warn-soft: #2a2114;
  --danger-soft: #2c1a18;
  --info-soft: #16233c;
  --ai-soft: #0f2628;

  --poster-bg: #121821;
  --poster-ink: #e9eef5;
  --poster-muted: #93a0ae;
  --poster-line: #29323d;
  --poster-soft: #1b242f;
  --sf-bg: #101720;
  --sf-ink: #e9eef5;
  --sf-muted: #93a0ae;
  --sf-line: #29323d;
  --sf-card: #171f29;

  --shadow-2: 0 4px 18px rgba(0, 0, 0, 0.4);
  --shadow-3: 0 20px 60px rgba(0, 0, 0, 0.55);
}

/* ---------- 8. Style presets (one-attribute re-skin) ---------- */
[data-style="warm"] {
  --bg: #f4f2ed;
  --paper: var(--bg);
  --surface-2: #faf8f3;
  --surface-3: #efece4;
  --line: #e4e0d6;
  --line-strong: #d3cec1;
  --text: #1d1a15;
  --text-2: #4a453c;
  --muted: #746d61;
  --faint: #9a9285;
  --a-500: #b0672a;
  --a-600: #93511c;
  --a-50: #fbf0e4;
  --a-200: #ecd4b8;
  --poster-bg: #fdfaf4;
  --poster-ink: #201c16;
  --sf-bg: #fcf9f3;
  --sf-ink: #211d17;
}

[data-style="graphite"] {
  --bg: #eef0f3;
  --paper: var(--bg);
  --surface-2: #f5f6f8;
  --surface-3: #e7eaee;
  --line: #d9dde3;
  --line-strong: #c3c9d1;
  --a-500: #3f6fae;
  --a-600: #335d94;
  --a-50: #eef3f9;
  --a-200: #cfdcea;
}

/* ---------- 9. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: var(--lh);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4, p { margin: 0; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-1);
}

::selection { background: var(--brand); color: #fff; }

/* Scrollbars — thin and quiet */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }
*::-webkit-scrollbar-track { background: transparent; }

/* Numerals behave like a ledger */
.mono, .num, kbd, .order-no {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.num, .money { font-variant-numeric: tabular-nums; }

/* Micro label — the signature of the product */
.micro {
  font-size: var(--fs-2xs);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

/* Paper grain — much quieter than before */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.28;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='120' height='120' filter='n' opacity='.03'/></svg>");
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* assets/css/primitives.css */
/* ============================================================
   BOXORDER 0100 — Component primitives
   Canonical layer. Every value comes from tokens.css.
   States covered: hover / active / focus-visible / disabled /
   loading / empty / error.
   ============================================================ */

/* ---------- Icons ---------- */
.ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--icon-2);
  height: var(--icon-2);
  flex: 0 0 auto;
  color: inherit;
}
.ico svg { width: 100%; height: 100%; display: block; }
.ico--sm { width: var(--icon-1); height: var(--icon-1); }
.ico--md { width: var(--icon-3); height: var(--icon-3); }
.ico--lg { width: var(--icon-4); height: var(--icon-4); }

/* ---------- Button ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  height: var(--control-h);
  padding: 0 var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface);
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  transition:
    background var(--dur-1) var(--ease),
    border-color var(--dur-1) var(--ease),
    color var(--dur-1) var(--ease),
    transform var(--dur-1) var(--ease);
}
.btn .ico { width: var(--icon-1); height: var(--icon-1); }
.btn:hover { border-color: var(--line-strong); background: var(--surface-2); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-soft), 0 0 0 1px var(--brand); }
.btn[disabled], .btn[aria-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
}
.btn--sm { height: var(--control-h-sm); padding: 0 var(--sp-2); font-size: var(--fs-xs); }
.btn--lg { height: var(--control-h-lg); padding: 0 var(--sp-4); font-size: var(--fs-md); }
.btn--brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--brand:hover { background: var(--brand-ink); border-color: var(--brand-ink); color: #fff; }
.btn--soft { background: var(--surface-2); border-color: var(--line); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn--ghost:hover { background: var(--surface-3); border-color: transparent; color: var(--text); }
.btn--danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 30%, var(--line));
  background: var(--danger-soft);
}
.btn--danger:hover { background: color-mix(in srgb, var(--danger-soft) 70%, var(--surface)); }
.btn--icon { width: var(--control-h); padding: 0; }

/* Loading — keeps width, swaps label for a spinner */
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading .ico { opacity: 0; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  color: var(--text-2);
  animation: bo-spin 700ms linear infinite;
}
.btn--brand.is-loading::after { color: #fff; }
@keyframes bo-spin { to { transform: rotate(360deg); } }

/* ---------- Icon button ---------- */
.icon-btn {
  position: relative;
  width: var(--control-h);
  height: var(--control-h);
  display: grid;
  place-items: center;
  border-radius: var(--r-2);
  color: var(--text-2);
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn:active { background: var(--line); }
.icon-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-soft), 0 0 0 1px var(--brand); }
.icon-btn[disabled] { opacity: 0.4; pointer-events: none; }
.icon-btn--ghost { color: var(--muted); }

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
.field > label {
  font-size: var(--fs-xs);
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.01em;
}
.field__hint { font-size: var(--fs-2xs); color: var(--faint); line-height: var(--lh-snug); }
.field__error { font-size: var(--fs-2xs); color: var(--danger); line-height: var(--lh-snug); }

.input, .select, textarea.input {
  width: 100%;
  min-width: 0;
  height: var(--control-h-lg);
  padding: 0 var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-sm);
  outline: none;
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
textarea.input { height: auto; padding: var(--sp-2) var(--sp-3); resize: vertical; line-height: var(--lh); }
.input::placeholder, textarea.input::placeholder { color: var(--faint); }
.input:hover, .select:hover, textarea.input:hover { border-color: var(--line-strong); }
.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.input[disabled], .select[disabled], textarea.input[disabled] {
  background: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.7;
}
.field.is-error .input,
.field.is-error .select,
.field.is-error textarea.input {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2377828f' stroke-width='2'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right var(--sp-3) center;
  padding-right: var(--sp-8);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }

/* Switch */
.switch {
  position: relative;
  width: 32px;
  height: 18px;
  flex: 0 0 32px;
  border-radius: var(--r-pill);
  background: var(--line-strong);
  transition: background var(--dur-2) var(--ease);
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-1);
  transition: transform var(--dur-2) var(--ease);
}
.switch.is-on { background: var(--brand); }
.switch.is-on::after { transform: translateX(14px); }
.switch:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 0 var(--sp-5);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 5;
}
.tab {
  position: relative;
  height: 38px;
  padding: 0 var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--muted);
  white-space: nowrap;
  border-radius: var(--r-1);
  transition: color var(--dur-1) var(--ease);
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); font-weight: 600; }
.tab.is-active::after {
  content: "";
  position: absolute;
  left: var(--sp-2); right: var(--sp-2); bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--brand);
}
.tab__count {
  margin-left: var(--sp-1);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-2xs);
  color: var(--faint);
}

/* ---------- Badge / tag / pill ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 20px;
  padding: 0 var(--sp-1);
  border-radius: var(--r-1);
  background: var(--surface-3);
  color: var(--muted);
  font-size: var(--fs-2xs);
  line-height: 1;
  white-space: nowrap;
}
.tag--real { background: var(--ok-soft); color: var(--ok); }
.tag--ai { background: var(--ai-soft); color: var(--ai); }
.tag--warn { background: var(--warn-soft); color: var(--warn); }
.tag--danger { background: var(--danger-soft); color: var(--danger); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  height: 20px;
  padding: 0 var(--sp-2);
  border: 1px solid transparent;
  border-radius: var(--r-1);
  font-size: var(--fs-2xs);
  font-weight: 500;
  white-space: nowrap;
}
.pill::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}
.pill--plain::before { display: none; }
.pill--ok { color: var(--ok); background: var(--ok-soft); }
.pill--warn { color: var(--warn); background: var(--warn-soft); }
.pill--danger { color: var(--danger); background: var(--danger-soft); }
.pill--info { color: var(--info); background: var(--info-soft); }
.pill--ai { color: var(--ai); background: var(--ai-soft); }
.pill--neutral { color: var(--muted); background: var(--surface-3); }

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
}
.card--pad { padding: var(--sp-3) var(--sp-4); }
.card--flush { overflow: hidden; }
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
}
.card__body { padding: var(--sp-3) var(--sp-4); }

/* ---------- Table ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  padding: var(--sp-2) var(--sp-3);
  text-align: left;
  font-size: var(--fs-2xs);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 3;
}
.table td {
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-sm);
  color: var(--text-2);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--dur-1) var(--ease); }
.table tbody tr:hover td { background: var(--surface-2); }
.table tr.is-selected td { background: var(--brand-soft); }
.table .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- Dialog / drawer / toast ---------- */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--n-900) 44%, transparent);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-3) var(--ease);
}
.scrim.is-open { opacity: 1; pointer-events: auto; }

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: var(--sp-4);
  pointer-events: none;
}
.modal {
  width: min(720px, 100%);
  max-height: min(88vh, 800px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-6);
  box-shadow: var(--shadow-3);
  pointer-events: auto;
  animation: bo-dialog-in var(--dur-3) var(--ease-out);
}
@keyframes bo-dialog-in {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: none; }
}
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
}
.modal__head h3 { font-size: var(--fs-xl); font-weight: 650; letter-spacing: var(--tracking-tight); }
.modal__head p { margin-top: 2px; font-size: var(--fs-xs); color: var(--muted); }
.modal__body { padding: var(--sp-4); overflow-y: auto; }
.modal__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.mobile-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 45;
  max-height: 86vh;
  display: none;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--r-6) var(--r-6) 0 0;
  box-shadow: var(--shadow-3);
  transform: translateY(102%);
  transition: transform var(--dur-3) var(--ease-out);
}
.mobile-sheet.is-open { transform: translateY(0); }
.mobile-sheet__grip {
  width: 36px; height: 4px;
  flex: 0 0 auto;
  margin: var(--sp-2) auto 2px;
  border-radius: 2px;
  background: var(--line-strong);
}
.mobile-sheet__body { overflow-y: auto; padding-bottom: env(safe-area-inset-bottom); }

.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: calc(var(--composer-h) + var(--sp-4));
  z-index: 60;
  width: min(92vw, 460px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  max-width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--r-3);
  background: var(--rail-1);
  color: var(--rail-text);
  font-size: var(--fs-xs);
  box-shadow: var(--shadow-2);
  animation: bo-toast-in var(--dur-2) var(--ease-out);
}
.toast .ico { width: var(--icon-1); height: var(--icon-1); color: #9fe0cd; }
@keyframes bo-toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Tooltip (opt-in via data-tip) ---------- */
[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%);
  z-index: 70;
  padding: 4px var(--sp-2);
  border-radius: var(--r-1);
  background: var(--rail-1);
  color: var(--rail-text);
  font-size: var(--fs-2xs);
  line-height: 1.4;
  white-space: nowrap;
  box-shadow: var(--shadow-2);
  pointer-events: none;
  animation: bo-fade-in var(--dur-1) var(--ease) both;
}
@keyframes bo-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Empty / error / skeleton ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-10) var(--sp-5);
  color: var(--muted);
  text-align: center;
}
.empty .ico { width: 32px; height: 32px; color: var(--faint); }
.empty b { font-size: var(--fs-lg); font-weight: 600; color: var(--text-2); }
.empty p { max-width: 280px; font-size: var(--fs-xs); line-height: var(--lh); }

.empty--error { color: var(--muted); }
.empty--error .ico { color: var(--danger); }
.empty--error b { color: var(--danger); }

.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%);
  background-size: 400% 100%;
  border-radius: var(--r-2);
  animation: bo-shimmer 1.4s var(--ease) infinite;
}
@keyframes bo-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ---------- Motion for panels / lists ---------- */
@keyframes bo-panel-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.panel-in { animation: bo-panel-in var(--dur-2) var(--ease-out) both; }

.stream-item, .sf-product, .tpl, .quick-btn, .tab, .nav-item {
  transition-duration: var(--dur-1);
  transition-timing-function: var(--ease);
}

/* ---------- Focus visibility, one system ---------- */
a:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ---------- Read-aloud bar ---------- */
.tts-bar {
  position: fixed;
  left: 0;
  right: 0;
  margin-left: auto;
  margin-right: auto;
  z-index: 45;
  width: min(680px, calc(100% - 24px));
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
  padding: 9px 10px 9px 12px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-4);
  box-shadow: var(--shadow-3);
  animation: bo-panel-in var(--dur-2) var(--ease-out) both;
}
.tts-bar[hidden] { display: none; }
.tts-bar__ico { display: inline-flex; color: var(--brand); }
.tts-bar__text { display: flex; flex-direction: column; min-width: 0; max-width: 190px; }
.tts-bar__text b {
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tts-bar__sub { font-size: var(--fs-2xs); color: var(--muted); white-space: nowrap; }
.tts-bar__meter { flex: 1 1 90px; min-width: 56px; display: flex; align-items: center; gap: var(--sp-2); }
.tts-bar__track { flex: 1; height: 4px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.tts-bar__track i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--brand);
  transition: width var(--dur-1) linear;
}
.tts-bar__meter span { font-size: var(--fs-2xs); color: var(--muted); white-space: nowrap; }
.tts-bar__actions { display: flex; align-items: center; gap: var(--sp-1); margin-left: auto; }
.tts-rate { display: flex; border: 1px solid var(--line); border-radius: var(--r-2); overflow: hidden; }
.tts-rate button {
  height: 22px;
  padding: 0 6px;
  border: 0;
  background: var(--surface);
  color: var(--muted);
  font-size: var(--fs-2xs);
}
.tts-rate button + button { border-left: 1px solid var(--line); }
.tts-rate button.is-on { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.tts-voice { width: 118px; height: 24px; padding: 0 6px; font-size: var(--fs-2xs); }
.tts-bar .icon-btn { width: 26px; height: 26px; }
.tts-bar .icon-btn .ico { width: var(--icon-1); height: var(--icon-1); }
.tts-bar__note { flex-basis: 100%; margin-top: 2px; font-size: var(--fs-2xs); color: var(--faint); }
.tts-bar.is-degraded .tts-bar__meter,
.tts-bar.is-degraded .tts-rate,
.tts-bar.is-degraded .tts-voice,
.tts-bar.is-degraded [data-act="play"],
.tts-bar.is-degraded [data-act="next"] { display: none; }
.tts-bar.is-degraded .tts-bar__text { max-width: 460px; }

@media (max-width: 560px) {
  .tts-bar { width: calc(100% - 16px); padding: 8px; gap: var(--sp-1) var(--sp-2); }
  .tts-bar__text { max-width: 92px; }
  .tts-bar__sub, .tts-voice { display: none; }
  .tts-bar__meter { flex-basis: 44px; }
}
@media (max-width: 480px) {
  .tts-bar__text { display: none; }
  .tts-bar__actions { margin-left: 0; }
  .tts-bar__note { order: 9; }
}

/* Reading highlight: one rule, no layout shift */
.tts-reading { outline: 2px solid var(--brand); outline-offset: 2px; }
.stream-item.tts-reading, .draft.tts-reading { background: var(--brand-soft); }

/* assets/css/shell.css */
/* ============================================================
   BOXORDER 0100 — Shell v2（TRAE 式左栏分区 + 中栏内容/BOT + 右栏检查器）
   依赖 tokens.css / primitives.css；不依赖 app.css / views.css
   ============================================================ */

html, body { height: 100%; margin: 0; }
body { overflow: hidden; background: var(--bg); }

.sh {
  display: flex;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}
body.is-drawer-open { overflow: hidden; }

/* ---------------- 左栏 ---------------- */
.sh-rail {
  width: 260px;
  flex: 0 0 260px;
  min-width: 0;
  background: var(--rail-1);
  color: var(--rail-text);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--rail-line);
  transition: width var(--dur-2) var(--ease), flex-basis var(--dur-2) var(--ease);
  z-index: 40;
}
.sh-rail.is-collapsed { width: 64px; flex-basis: 64px; }

.sh-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--rail-line);
  min-height: 52px;
}
.sh-brand__mark {
  width: 30px; height: 30px; flex: 0 0 30px;
  border-radius: 8px;
  background: linear-gradient(160deg, #2b5fd6, #1b3f96);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.sh-brand__mark svg { width: 18px; height: 18px; }
.sh-brand__type { min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.sh-brand__type b { font-size: 13px; letter-spacing: .02em; }
.sh-brand__type i { font-style: normal; font-size: 9px; color: var(--rail-muted); letter-spacing: .12em; }
.sh-rail__toggle {
  margin-left: auto;
  width: 26px; height: 26px; border-radius: 6px;
  color: var(--rail-muted);
  display: flex; align-items: center; justify-content: center;
}
.sh-rail__toggle:hover { background: rgba(255,255,255,.06); color: #fff; }
.sh-rail__toggle svg { width: 15px; height: 15px; }

.sh-groups { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 6px 8px 12px; }
.sh-groups::-webkit-scrollbar { width: 6px; }

.sh-group { margin-top: 6px; }
.sh-group__head {
  width: 100%;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 6px;
  border-radius: 6px;
  color: var(--rail-muted);
  font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-align: left;
}
.sh-group__head:hover { color: var(--rail-text); background: rgba(255,255,255,.04); }
.sh-group__head svg { width: 14px; height: 14px; flex: 0 0 14px; opacity: .9; }
.sh-group__head .sh-g__chev { margin-left: auto; width: 12px; height: 12px; transition: transform var(--dur-2) var(--ease); }
.sh-group.is-collapsed .sh-g__chev { transform: rotate(-90deg); }
.sh-group.is-collapsed .sh-group__body { display: none; }
.sh-group__body { padding: 2px 0 6px; }

.sh-item {
  width: 100%;
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px 7px 10px;
  border-radius: 6px;
  color: var(--rail-text);
  font-size: 12.5px;
  text-align: left;
  opacity: .92;
}
.sh-item:hover { background: rgba(255,255,255,.06); opacity: 1; }
.sh-item.is-active { background: rgba(92, 133, 224, .18); box-shadow: inset 0 0 0 1px rgba(92,133,224,.35); }
.sh-item__ico { width: 15px; height: 15px; flex: 0 0 15px; display: flex; align-items: center; justify-content: center; color: var(--rail-muted); }
.sh-item.is-active .sh-item__ico { color: #a9c2ff; }
.sh-item__label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh-item__badge {
  min-width: 16px; height: 16px; padding: 0 5px;
  border-radius: 9px; background: var(--a-500); color: #fff;
  font-size: 10px; font-weight: 600; display: flex; align-items: center; justify-content: center;
}
.sh-item__dot { width: 6px; height: 6px; border-radius: 50%; background: #ff5f56; flex: 0 0 6px; }
.sh-item__time { font-size: 10px; color: var(--rail-muted); flex: 0 0 auto; }

/* 左栏二级列表（订单 / 会话 / 项目） */
.sh-list { display: flex; flex-direction: column; gap: 1px; }
.sh-list__item {
  width: 100%; text-align: left;
  padding: 7px 8px 7px 10px; border-radius: 6px;
  color: var(--rail-text);
  display: flex; flex-direction: column; gap: 2px;
}
.sh-list__item:hover { background: rgba(255,255,255,.06); }
.sh-list__item.is-active { background: rgba(92,133,224,.18); box-shadow: inset 0 0 0 1px rgba(92,133,224,.35); }
.sh-list__row1 { display: flex; align-items: center; gap: 6px; min-width: 0; }
.sh-list__title { font-size: 12px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; }
.sh-list__meta { display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--rail-muted); min-width: 0; }
.sh-list__preview { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh-list__empty { padding: 10px; font-size: 11px; color: var(--rail-muted); line-height: 1.5; }

.sh-seg {
  display: flex; gap: 4px; margin: 4px 0 6px; padding: 0 6px;
}
.sh-seg button {
  flex: 1 1 0;
  height: 24px; border-radius: 5px;
  font-size: 11px; color: var(--rail-muted);
  border: 1px solid transparent;
}
.sh-seg button.is-on { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.14); }

.sh-group__sub {
  padding: 2px 6px 4px; font-size: 10px; color: var(--rail-muted);
  letter-spacing: .08em;
}

.sh-rail__foot {
  border-top: 1px solid var(--rail-line);
  padding: 10px;
  display: flex; align-items: center; gap: 8px;
}
.sh-user {
  width: 26px; height: 26px; flex: 0 0 26px; border-radius: 50%;
  background: rgba(255,255,255,.1); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
}
.sh-user__meta { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.sh-user__meta b { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh-user__meta i { font-style: normal; font-size: 10px; color: var(--rail-muted); }

/* 折叠到 64px */
.sh-rail.is-collapsed .sh-brand__type,
.sh-rail.is-collapsed .sh-group__head > span,
.sh-rail.is-collapsed .sh-g__chev,
.sh-rail.is-collapsed .sh-item__label,
.sh-rail.is-collapsed .sh-item__time,
.sh-rail.is-collapsed .sh-item__badge,
.sh-rail.is-collapsed .sh-list,
.sh-rail.is-collapsed .sh-seg,
.sh-rail.is-collapsed .sh-user__meta { display: none; }
.sh-rail.is-collapsed .sh-group__head { justify-content: center; }
.sh-rail.is-collapsed .sh-item { justify-content: center; padding: 8px; }
.sh-rail.is-collapsed .sh-rail__foot { justify-content: center; }

/* ---------------- 中栏 ---------------- */
.sh-main {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}
.sh-content {
  flex: 3 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  overflow: hidden;
}
.sh-main.is-bot-collapsed .sh-bot { flex: 0 0 46px; }

.sh-head {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  min-height: 48px;
  background: var(--surface);
  z-index: 2;
}
.sh-head__titles { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.sh-head__crumb { font-size: 10px; color: var(--muted); letter-spacing: .06em; }
.sh-head__title { font-size: 14.5px; font-weight: 650; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh-head__spacer { flex: 1 1 auto; }
.sh-head__sub { font-size: 11px; color: var(--muted); white-space: nowrap; }
.sh-head .btn--brand { flex: 0 0 auto; }
.sh-head .sh-primary:hover { background: var(--brand-ink); }

.sh-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 16px; }
.sh-scroll--tight { padding: 10px 14px; }
.sh-scroll--chat { padding: 0; overflow: hidden; display: flex; flex-direction: column; }

.sh-sec { margin-bottom: 18px; }
.sh-sec:last-child { margin-bottom: 4px; }
.sh-sec__title { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sh-sec__title h3 { font-size: 12px; font-weight: 650; letter-spacing: .02em; }
.sh-sec__title .micro { margin-left: auto; }

.sh-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-4);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.sh-card + .sh-card { margin-top: 10px; }
.sh-card__pad { padding: 14px; }
.sh-card__head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.sh-card__head b { font-size: 12.5px; }
.sh-card__head .micro { margin-left: auto; }

.sh-grid { display: grid; gap: 10px; }
.sh-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sh-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sh-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.sh-kpi {
  border: 1px solid var(--line);
  border-radius: var(--r-4);
  background: var(--surface);
  padding: 12px 14px;
  box-shadow: var(--shadow-1);
  min-width: 0;
}
.sh-kpi .k { font-size: 10.5px; color: var(--muted); letter-spacing: .04em; display: flex; align-items: center; gap: 5px; }
.sh-kpi .v { font-size: 22px; font-weight: 680; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.sh-kpi .s { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.sh-kpi .v.is-warn { color: var(--warn); }
.sh-kpi .v.is-ok { color: var(--ok); }

.sh-store {
  display: flex; align-items: center; gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-5);
  background:
    radial-gradient(120% 160% at 0% 0%, var(--brand-soft) 0%, transparent 45%),
    var(--surface);
  box-shadow: var(--shadow-1);
}
.sh-store__logo {
  width: 54px; height: 54px; flex: 0 0 54px; border-radius: 12px;
  background: linear-gradient(160deg, #2b5fd6, #1b3f96);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 650;
}
.sh-store__main { min-width: 0; flex: 1 1 auto; }
.sh-store__name { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 660; }
.sh-store__meta { font-size: 11.5px; color: var(--muted); margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; }
.sh-store__desc { font-size: 12px; color: var(--text-2); margin-top: 8px; line-height: 1.55; max-width: 640px; }

.sh-chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 18px; padding: 0 7px; border-radius: 9px;
  font-size: 10px; font-weight: 600; letter-spacing: .02em;
  background: var(--surface-3); color: var(--text-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.sh-chip--ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 22%, transparent); }
.sh-chip--warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 22%, transparent); }
.sh-chip--brand { background: var(--brand-soft); color: var(--brand-ink); border-color: var(--brand-line); }
.sh-chip--ai { background: var(--ai-soft); color: var(--ai); border-color: color-mix(in srgb, var(--ai) 22%, transparent); }

.sh-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.sh-row:last-child { border-bottom: 0; }
.sh-row:hover { background: var(--surface-2); }
.sh-row__main { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; }
.sh-row__title { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh-row__meta { font-size: 10.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh-row__side { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

.sh-thumb {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 8px;
  background: var(--surface-3); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 11px;
}
.sh-thumb img { width: 100%; height: 100%; object-fit: cover; }

.sh-empty {
  padding: 28px 18px; text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-4);
  color: var(--muted); font-size: 12px; line-height: 1.6;
  background: var(--surface-2);
}
.sh-empty b { display: block; color: var(--text-2); font-size: 12.5px; margin-bottom: 3px; }

.sh-note {
  font-size: 11.5px; color: var(--muted); line-height: 1.55;
  padding: 9px 11px; border-radius: var(--r-3);
  background: var(--surface-2); border: 1px solid var(--line);
}
.sh-note--ai { background: var(--ai-soft); border-color: color-mix(in srgb, var(--ai) 18%, transparent); color: var(--text-2); }

/* 模板缩略图（静态占位，标注待接入） */
.sh-tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.sh-tpl {
  border: 1px solid var(--line); border-radius: var(--r-4);
  background: var(--surface); overflow: hidden; box-shadow: var(--shadow-1);
}
.sh-tpl__art { height: 118px; position: relative; background: var(--surface-3); }
.sh-tpl__art svg { width: 100%; height: 100%; display: block; }
.sh-tpl__badge { position: absolute; top: 8px; left: 8px; font-size: 9.5px; }
.sh-tpl__meta { padding: 10px 12px; display: flex; align-items: center; gap: 8px; }
.sh-tpl__meta b { font-size: 12px; }
.sh-tpl__meta span { margin-left: auto; font-size: 10px; color: var(--muted); }
.sh-tpl.is-on { border-color: var(--brand-line); box-shadow: inset 0 0 0 1px var(--brand-line), var(--shadow-1); }
.sh-tpl > .btn { margin: 0 12px 12px; }

/* 订单卡片 */
.sh-order {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.sh-order:last-child { border-bottom: 0; }
.sh-order:hover { background: var(--surface-2); }
.sh-order.is-active { background: var(--brand-soft); }
.sh-order__main { min-width: 0; flex: 1 1 auto; }
.sh-order__no { font-size: 12px; font-weight: 650; font-family: var(--mono); }
.sh-order__meta { font-size: 10.5px; color: var(--muted); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.sh-order__side { text-align: right; flex: 0 0 auto; }
.sh-order__amt { font-size: 12.5px; font-weight: 650; font-variant-numeric: tabular-nums; }
.sh-order__stage { font-size: 10px; color: var(--muted); }

/* 阶段条 */
.sh-stages { display: flex; gap: 0; margin: 12px 0 16px; }
.sh-stage {
  flex: 1 1 0; min-width: 0;
  text-align: center; padding-top: 8px;
  position: relative; font-size: 10px; color: var(--faint);
}
.sh-stage::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--line);
}
.sh-stage.is-done::before { background: var(--ok); }
.sh-stage.is-now::before { background: var(--brand); }
.sh-stage.is-now { color: var(--brand-ink); font-weight: 650; }
.sh-stage__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }

/* 聊天 */
.sh-chat { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.sh-chat__head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.sh-chat__head b { font-size: 13px; }
.sh-chat__head .micro { margin-left: auto; }
.sh-chat__log { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.sh-msg { max-width: min(78%, 560px); display: flex; flex-direction: column; gap: 3px; }
.sh-msg.is-me { align-self: flex-end; align-items: flex-end; }
.sh-msg__bubble {
  padding: 8px 11px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word;
}
.sh-msg.is-me .sh-msg__bubble { background: var(--brand); border-color: var(--brand); color: #fff; }
.sh-msg__meta { font-size: 10px; color: var(--muted); }
.sh-chat__compose {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 10px 14px; border-top: 1px solid var(--line);
  background: var(--surface);
}
.sh-chat__input {
  flex: 1 1 auto;
  min-height: 32px; max-height: 96px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12.5px;
  background: var(--surface-2);
  color: var(--text);
}
.sh-chat__input:focus { outline: none; border-color: var(--brand-line); background: var(--surface); }
.sh-send {
  width: 32px; height: 32px; flex: 0 0 32px; border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
}
.sh-send:hover { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand-ink); }
.sh-send[disabled] { opacity: .45; pointer-events: none; }

/* 动态 */
.sh-post {
  border: 1px solid var(--line); border-radius: var(--r-4);
  background: var(--surface); box-shadow: var(--shadow-1);
  padding: 12px 14px; margin-bottom: 10px;
}
.sh-post__top { display: flex; align-items: center; gap: 8px; }
.sh-post__avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-ink); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 650; }
.sh-post__who { min-width: 0; }
.sh-post__who b { font-size: 12px; }
.sh-post__who i { font-style: normal; font-size: 10px; color: var(--muted); display: block; }
.sh-post__top .sh-chip { margin-left: auto; }
.sh-post__body { font-size: 12.5px; line-height: 1.65; margin: 9px 0; white-space: pre-wrap; }
.sh-post__media { border-radius: 8px; overflow: hidden; border: 1px solid var(--line); margin: 8px 0; }
.sh-post__media img { width: 100%; max-height: 260px; object-fit: cover; }
.sh-post__links { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 2px; }
.sh-post__actions { display: flex; gap: 14px; align-items: center; padding-top: 8px; border-top: 1px solid var(--line); margin-top: 8px; }
.sh-post__act { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); }
.sh-post__act:hover { color: var(--brand-ink); }

/* ---------------- BOT 坞 ---------------- */
.sh-bot {
  flex: 2 1 0;
  min-height: 0;
  display: flex; flex-direction: column;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  transition: flex-basis var(--dur-2) var(--ease);
  overflow: hidden;
}
.sh-bot.is-collapsed { flex: 0 0 46px; }
.sh-bot__bar {
  flex: 0 0 auto;
  height: 46px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px;
  border-bottom: 1px solid transparent;
}
.sh-bot.is-collapsed .sh-bot__bar { border-bottom-color: var(--line); }
.sh-bot__face {
  width: 24px; height: 24px; border-radius: 7px;
  background: var(--ai-soft); color: var(--ai);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  border: 1px solid color-mix(in srgb, var(--ai) 20%, transparent);
}
.sh-bot__name { font-size: 12px; font-weight: 650; }
.sh-bot__ctx { font-size: 10.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh-bot__bar .sh-seg { margin: 0 0 0 8px; padding: 0; max-width: 200px; }
.sh-bot__bar .sh-seg button { height: 22px; font-size: 10px; color: var(--muted); border-color: var(--line); }
.sh-bot__bar .sh-seg button.is-on { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.sh-bot__spacer { flex: 1 1 auto; }
.sh-bot__collapse { width: 26px; height: 26px; border-radius: 6px; color: var(--muted); display: flex; align-items: center; justify-content: center; }
.sh-bot__collapse:hover { background: var(--surface-3); color: var(--text); }
.sh-bot__body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.sh-bot.is-collapsed .sh-bot__body { display: none; }
.sh-bot__log { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.sh-bot__compose { display: flex; gap: 8px; align-items: flex-end; padding: 9px 14px 12px; border-top: 1px solid var(--line); }
.sh-bot__input {
  flex: 1 1 auto; min-height: 34px; max-height: 84px; resize: none;
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
  font-size: 12.5px; background: var(--surface); color: var(--text);
}
.sh-bot__input:focus { outline: none; border-color: var(--brand-line); }
.sh-bot__hint { font-size: 10.5px; color: var(--muted); padding: 0 14px 10px; }
.sh-bot__empty { margin: auto; max-width: 460px; text-align: center; }
.sh-bot__empty .sh-note { text-align: left; }

/* ---------------- 右栏检查器 ---------------- */
.sh-ins {
  width: 320px;
  flex: 0 0 320px;
  min-width: 0;
  border-left: 1px solid var(--line);
  background: var(--surface);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sh-ins__head {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  min-height: 48px;
}
.sh-ins__head b { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh-ins__head .micro { margin-left: auto; }
.sh-ins__close { display: none; width: 26px; height: 26px; border-radius: 6px; color: var(--muted); }
.sh-ins__body { flex: 1 1 auto; overflow-y: auto; padding: 12px 14px 24px; }
.sh-ins__sec { padding: 10px 0; border-bottom: 1px solid var(--line); }
.sh-ins__sec:last-child { border-bottom: 0; }
.sh-ins__sec h4 { font-size: 10px; letter-spacing: .08em; color: var(--muted); font-weight: 650; text-transform: uppercase; margin-bottom: 7px; }
.sh-kv { display: flex; align-items: baseline; gap: 8px; font-size: 11.5px; padding: 3px 0; }
.sh-kv span { color: var(--muted); flex: 0 0 64px; }
.sh-kv b { font-weight: 500; color: var(--text); flex: 1 1 auto; word-break: break-word; }
.sh-kv b.num { font-weight: 650; }
.sh-ins__actions { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 10px; }
.sh-ins__actions .btn { height: 26px; font-size: 11px; }

/* ---------------- 抽屉 / 遮罩 ---------------- */
.sh-scrim {
  position: fixed; inset: 0; z-index: 35;
  background: rgba(12, 18, 26, .38);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-2) var(--ease);
}
.sh-scrim.is-on { opacity: 1; pointer-events: auto; }

@media (max-width: 1180px) {
  .sh-ins {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 45;
    width: min(360px, 92vw);
    transform: translateX(102%);
    transition: transform var(--dur-3) var(--ease-out);
    box-shadow: var(--shadow-3);
  }
  .sh-ins.is-open { transform: translateX(0); }
  .sh-ins__close { display: flex; align-items: center; justify-content: center; }
}

@media (max-width: 768px) {
  .sh-rail {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 46;
    width: min(280px, 86vw);
    flex-basis: 0;
    transform: translateX(-102%);
    transition: transform var(--dur-3) var(--ease-out);
  }
  .sh-rail.is-open { transform: translateX(0); }
  .sh-rail.is-collapsed { width: min(280px, 86vw); transform: translateX(-102%); }
  .sh-rail.is-collapsed.is-open { transform: translateX(0); }
  .sh-main { flex: 1 1 100%; }
  .sh-head { padding: 8px 12px; min-height: 44px; }
  .sh-scroll { padding: 12px; }
  .sh-bot { flex: 2 1 0; }
  .sh-bot.is-collapsed { flex: 0 0 44px; }
  .sh-grid--4, .sh-grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sh-msg { max-width: 88%; }
}

@media (max-width: 420px) {
  .sh-grid--4, .sh-grid--3, .sh-grid--2 { grid-template-columns: 1fr; }
  .sh-head__sub { display: none; }
  .sh-kpi .v { font-size: 19px; }
  .sh-store { padding: 12px; gap: 10px; }
  .sh-store__logo { width: 44px; height: 44px; flex-basis: 44px; font-size: 18px; }
  .sh-store__name { font-size: 14px; }
  .sh-tpl-grid { grid-template-columns: 1fr; }
}

/* 通用表单 */
.sh-form { display: flex; flex-direction: column; gap: 10px; }
.sh-field { display: flex; flex-direction: column; gap: 4px; }
.sh-field > label { font-size: 10.5px; color: var(--muted); letter-spacing: .04em; }
.sh-field input, .sh-field select, .sh-field textarea {
  height: 32px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--surface-2); color: var(--text); padding: 0 9px; font-size: 12.5px;
}
.sh-field textarea { height: 76px; padding: 7px 9px; resize: vertical; }
.sh-field input:focus, .sh-field select:focus, .sh-field textarea:focus { outline: none; border-color: var(--brand-line); background: var(--surface); }
.sh-modal {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(12, 18, 26, .42);
}
.sh-modal__card {
  width: min(440px, 94vw); max-height: 88vh; overflow: auto;
  background: var(--surface); border-radius: 12px; border: 1px solid var(--line);
  box-shadow: var(--shadow-3);
}
.sh-modal__head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.sh-modal__head b { font-size: 13px; }
.sh-modal__head button { margin-left: auto; width: 26px; height: 26px; border-radius: 6px; color: var(--muted); }
.sh-modal__body { padding: 14px; }
.sh-modal__foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 14px; border-top: 1px solid var(--line); }
.sh-submit {
  height: 32px; padding: 0 14px; border-radius: 7px;
  background: var(--brand); color: #fff; border: 1px solid var(--brand);
  font-size: 12px; font-weight: 600;
}
.sh-submit:hover { background: var(--brand-ink); }
.sh-submit[disabled] { opacity: .5; pointer-events: none; }

/* ---------- A1 多步上架向导 ---------- */
.sh-wizard { width: min(560px, 94vw); }
.sh-wz-count { font-size: 11px; color: var(--muted); margin-left: auto; font-variant-numeric: tabular-nums; }
.sh-wizard .sh-modal__head button { margin-left: 8px; }
.sh-steps { display: flex; gap: 4px; padding: 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.sh-step { display: flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--faint); padding: 3px 7px 3px 3px; border-radius: var(--r-pill); }
.sh-step__dot {
  width: 17px; height: 17px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-3); color: var(--muted); font-size: 10px; font-weight: 700;
}
.sh-step.is-on { color: var(--brand-ink); background: var(--brand-soft); }
.sh-step.is-on .sh-step__dot { background: var(--brand); color: #fff; }
.sh-step.is-done { color: var(--ok); }
.sh-step.is-done .sh-step__dot { background: var(--ok-soft); color: var(--ok); }
.sh-req { color: var(--danger); font-size: 10px; font-weight: 600; }
.sh-form__err { margin-top: 10px; padding: 7px 9px; border-radius: var(--r-2); background: var(--danger-soft); color: var(--danger); font-size: 11.5px; }
.sh-price-row { border: 1px solid var(--line); border-radius: var(--r-3); padding: 9px 10px; background: var(--surface-2); }
.sh-price-row.is-main { border-color: var(--brand-line); background: var(--brand-soft); }
.sh-price-row__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.sh-price-row__head b { font-size: 12px; }
.sh-price-row .sh-field { margin-top: 4px; }
.sh-wz-preview {
  height: 132px; border: 1px dashed var(--line-strong); border-radius: var(--r-3);
  background: var(--surface-2); display: grid; place-items: center;
  color: var(--faint); font-size: 11px; overflow: hidden;
}
.sh-wz-preview img { width: 100%; height: 100%; object-fit: cover; }
.sh-summary__media {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px; border: 1px solid var(--line); border-radius: var(--r-3); background: var(--surface-2);
}
.sh-summary__media img { width: 76px; height: 60px; object-fit: cover; border-radius: var(--r-2); }
.sh-summary__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin-top: 10px; }
.sh-summary__prices { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.sh-summary__prices h4 { font-size: 11px; color: var(--muted); margin-bottom: 6px; letter-spacing: .04em; }

/* ---------- B1 订单详情：A–K 分段 ---------- */
.sh-osec { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.sh-osec:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.sh-osec__title { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.sh-osec__title i {
  font-style: normal; width: 16px; height: 16px; border-radius: var(--r-1);
  background: var(--surface-3); color: var(--muted); font-size: 9.5px; font-weight: 700;
  display: grid; place-items: center; flex: 0 0 16px;
}
.sh-osec__title b { font-size: 11.5px; letter-spacing: .02em; }
.sh-osec__title span { margin-left: auto; font-size: 10px; color: var(--faint); }
.sh-otable { width: 100%; border-collapse: collapse; font-size: 10.5px; }
.sh-otable th { text-align: left; color: var(--faint); font-weight: 500; padding: 3px 0; border-bottom: 1px solid var(--line); }
.sh-otable td { padding: 5px 0; border-bottom: 1px solid var(--surface-3); vertical-align: top; }
.sh-otable td.num, .sh-otable th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sh-otable .sh-othumb { width: 26px; height: 22px; object-fit: cover; border-radius: var(--r-1); background: var(--surface-3); }
.sh-oline { display: flex; gap: 8px; align-items: baseline; padding: 4px 0; border-bottom: 1px solid var(--surface-3); font-size: 10.5px; }
.sh-oline:last-child { border-bottom: 0; }
.sh-oline .t { color: var(--faint); flex: 0 0 38px; font-variant-numeric: tabular-nums; }
.sh-oline .m { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh-oline .y { color: var(--muted); flex: 0 0 auto; }
.sh-miss { font-size: 10.5px; color: var(--warn); background: var(--warn-soft); border-radius: var(--r-2); padding: 5px 7px; }
.sh-ochips { display: flex; flex-wrap: wrap; gap: 4px; }

@media (max-width: 420px) {
  .sh-summary__grid { grid-template-columns: 1fr; }
  .sh-step { font-size: 9.5px; }
  .sh-step__dot { width: 15px; height: 15px; }
}

/* 登录 */
.sh-login { max-width: 420px; margin: 6vh auto 0; }
.sh-login__card { padding: 20px; }
.sh-login__brand { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sh-login__brand .sh-brand__mark { background: linear-gradient(160deg, #2b5fd6, #1b3f96); }
.sh-login__title { font-size: 16px; font-weight: 660; }
.sh-login__sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.sh-login__note { margin-top: 10px; }

/* 空态 / 加载 */
.sh-loading { padding: 40px 0; text-align: center; color: var(--muted); font-size: 12px; }
.sh-spinner {
  width: 18px; height: 18px; margin: 0 auto 8px;
  border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--brand);
  animation: shspin .8s linear infinite;
}
@keyframes shspin { to { transform: rotate(360deg); } }

.sh-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 80; display: flex; flex-direction: column; gap: 6px; align-items: center;
  pointer-events: none;
}
.sh-toast__item {
  background: var(--n-900); color: #fff; font-size: 12px;
  padding: 8px 14px; border-radius: 8px; box-shadow: var(--shadow-2);
  max-width: 84vw;
}
.sh-toast__item.is-warn { background: var(--warn); }
.sh-toast__item.is-err { background: var(--danger); }

/* ============================================================
   B3 · 邀请二维码 / 定制闭环 / BOT 草稿（仅用现有 tokens）
   ============================================================ */
.sh-modal__card { max-height: 88vh; overflow: auto; }
.sh-invite-out { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.sh-invite__qr { width: 148px; height: 148px; border: 1px solid var(--line); border-radius: var(--r-2); display: grid; place-items: center; background: var(--surface); }
.sh-invite__qr svg { width: 132px; height: 132px; display: block; }
.sh-invite__link { display: block; font-size: 10px; line-height: 1.6; word-break: break-all; background: var(--surface-2); padding: 6px 8px; border-radius: var(--r-2); color: var(--text-2); }

.sh-custom__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .sh-custom__grid { grid-template-columns: 1fr; } }
.sh-custom__label { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.sh-custom__approved { display: flex; gap: 8px; align-items: center; padding: 8px; border: 1px solid var(--ok); border-radius: var(--r-2); background: var(--ok-soft); }
.sh-custom__approved img { width: 60px; height: 60px; object-fit: cover; border-radius: var(--r-2); flex: 0 0 60px; }
.sh-custom__asset { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 8px; border: 1px solid var(--line); border-radius: var(--r-2); margin-top: 6px; min-width: 0; }
.sh-custom__asset.is-dead { opacity: .55; }
.sh-custom__assetmain { min-width: 0; overflow-wrap: anywhere; }
.sh-custom__quote { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 8px; border: 1px solid var(--line); border-radius: var(--r-2); margin-bottom: 6px; min-width: 0; }
.sh-custom__quote > div { min-width: 0; overflow-wrap: anywhere; }
.sh-custom__confirm { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }

.sh-botdraft__bar { display: flex; gap: 8px; align-items: center; padding: 6px 10px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.sh-botdraft__cap { font-size: 10px; font-weight: 600; color: var(--brand); letter-spacing: .04em; }
.sh-botdraft__select { max-width: 150px; height: 26px; font-size: 11px; }
.sh-botdraft__off { font-size: 11px; color: var(--muted); flex: 1; min-width: 120px; }
.sh-botdraft__run { padding: 8px 10px; border-top: 1px solid var(--line); background: var(--surface-2); }
.sh-botdraft__runbody { font-size: 12px; color: var(--text-2); overflow-wrap: anywhere; }
.sh-botdraft__runmeta { font-size: 10px; color: var(--muted); margin-top: 3px; }
