/* ============================================================
   Doubao Design System — Strict Component Styles
   Source: Doubao Design System + Strict Design Specs Package
   ============================================================ */

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 24px;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: var(--font-size-body);
  line-height: 1.4;
}

/* ============================================================
   SHARED: .icon — 通用线条图标
   @anatomy <svg class="icon">...</svg>
   ============================================================ */
.icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}
.icon.icon-sm { width: 14px; height: 14px; stroke-width: 1.8; }
.icon.icon-lg { width: 18px; height: 18px; stroke-width: 1.7; }

/* ============================================================
   SHARED: .label — 等宽大写标签
   @anatomy <span class="label">LABEL</span>
   ============================================================ */
.label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-foreground);
  line-height: 1;
}

/* ============================================================
   SHARED: .divider — 水平分隔线
   @anatomy <hr class="divider">
   ============================================================ */
.divider {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 0;
}

/* ============================================================
   BUTTON .btn — 胶囊形按钮
   @anatomy
   <button class="btn [primary|ghost|outline|destructive] [sm|lg] [icon-only]">
     [svg.icon]
     <span>Label</span>
   </button>
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: all 120ms cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
.btn:disabled,
.btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.6;
  pointer-events: none;
}

/* --- sizes --- */
.btn.sm {
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
  gap: 4px;
}
.btn.sm .icon { width: 14px; height: 14px; }
.btn.lg {
  height: 44px;
  padding: 0 20px;
  font-size: 16px;
  gap: 8px;
}
.btn.lg .icon { width: 18px; height: 18px; }
.btn.icon-only {
  padding: 0;
  width: 38px;
  min-width: 38px;
}
.btn.icon-only.sm { width: 32px; min-width: 32px; }
.btn.icon-only.lg { width: 44px; min-width: 44px; }

/* --- primary --- */
.btn.primary {
  background: var(--primary);
  color: var(--primary-foreground);
  border: none;
  box-shadow: none;
}
.btn.primary:hover {
  background: color-mix(in srgb, var(--primary) 88%, #000000);
  box-shadow: 0 1px 2px rgba(14,17,21,0.04);
}
.btn.primary:active {
  background: color-mix(in srgb, var(--primary) 78%, #000000);
}
.btn.primary:focus-visible {
  background: var(--primary);
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
.btn.primary:disabled {
  background: var(--muted);
  color: var(--muted-foreground);
}

/* --- outline (secondary) --- */
.btn.outline,
.btn.secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
  border: 1px solid var(--border);
  box-shadow: none;
}
.btn.outline:hover,
.btn.secondary:hover {
  background: color-mix(in srgb, var(--secondary) 70%, var(--primary) 8%);
  border-color: color-mix(in srgb, var(--border) 80%, var(--primary));
}
.btn.outline:active,
.btn.secondary:active {
  background: color-mix(in srgb, var(--secondary) 60%, var(--primary) 12%);
}
.btn.outline:focus-visible,
.btn.secondary:focus-visible {
  background: var(--secondary);
  border: 1.5px solid var(--primary);
  outline: none;
}
.btn.outline:disabled,
.btn.secondary:disabled {
  background: var(--muted);
  color: var(--muted-foreground);
  border-color: var(--border);
}

/* --- ghost --- */
.btn.ghost {
  background: transparent;
  color: var(--foreground);
  border: 1px solid transparent;
  box-shadow: none;
}
.btn.ghost:hover {
  background: var(--muted);
}
.btn.ghost:active {
  background: color-mix(in srgb, var(--muted) 80%, var(--primary) 10%);
}
.btn.ghost:focus-visible {
  background: var(--accent);
  color: var(--accent-foreground);
  border: 1.5px solid var(--primary);
  outline: none;
}
.btn.ghost:disabled {
  background: transparent;
  color: var(--muted-foreground);
  opacity: 0.5;
}

/* --- destructive --- */
.btn.destructive {
  background: var(--destructive);
  color: var(--destructive-foreground);
  border: none;
  box-shadow: none;
}
.btn.destructive:hover {
  background: color-mix(in srgb, var(--destructive) 88%, #000000);
  box-shadow: 0 1px 2px rgba(14,17,21,0.04);
}
.btn.destructive:active {
  background: color-mix(in srgb, var(--destructive) 78%, #000000);
}
.btn.destructive:focus-visible {
  background: var(--destructive);
  outline: 2px solid color-mix(in srgb, var(--destructive) 50%, var(--ring));
  outline-offset: 2px;
}
.btn.destructive:disabled {
  background: var(--muted);
  color: var(--muted-foreground);
}

/* ============================================================
   SEARCH .search — 搜索输入框
   @anatomy
   <div class="search [filled] [disabled] [error]">
     <svg class="icon search-ic">...</svg>
     <input type="text" placeholder="...">
     <span class="kbd">⌘K</span>
     <button class="clear"><svg class="icon">...</svg></button>
   </div>
   ============================================================ */
.search {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--input);
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 14px;
  transition: border-color 120ms cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 120ms cubic-bezier(0.4, 0, 0.2, 1),
              background 120ms cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 200px;
  max-width: 100%;
}
.search > input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  line-height: 1.5;
  padding: 0;
  min-width: 0;
}
.search > input::placeholder { color: var(--muted-foreground); }
.search > .search-ic {
  color: var(--muted-foreground);
  flex-shrink: 0;
  transition: color 120ms cubic-bezier(0.4, 0, 0.2, 1);
}
.search:focus-within {
  border-color: var(--primary);
  border-width: 1.5px;
  padding: 0 11.5px;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
}
.search:focus-within > .search-ic { color: var(--primary); }
.search .kbd {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--muted);
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity 120ms ease;
}
.search:focus-within .kbd,
.search.has-value .kbd {
  display: none;
}
.search .clear {
  display: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 120ms ease, color 120ms ease;
}
.search .clear:hover {
  background: var(--muted);
  color: var(--foreground);
}
.search.has-value .clear,
.search.error .clear { display: inline-flex; }
.search.has-value:focus-within .kbd { display: none; }

/* --- filled variant (pill, muted bg) --- */
.search.filled {
  border-radius: 999px;
  background: var(--muted);
  border-color: transparent;
}
.search.filled:focus-within {
  background: var(--background);
  border-color: var(--primary);
  border-width: 1.5px;
  padding: 0 11.5px;
}

/* --- sizes --- */
.search.sm { height: 32px; font-size: 12px; }
.search.lg { height: 44px; font-size: 14px; padding: 0 16px; border-radius: 999px; }
.search.lg.filled { border-radius: 999px; }

/* --- states --- */
.search.disabled,
.search:has(input:disabled) {
  background: var(--muted);
  border-color: var(--border);
  color: var(--muted-foreground);
  cursor: not-allowed;
  opacity: 0.6;
}
.search.disabled > input,
.search:has(input:disabled) > input { cursor: not-allowed; }
.search.error {
  border-color: var(--state-error);
  border-width: 1.5px;
  padding: 0 11.5px;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--state-error) 12%, transparent);
}
.search.error > .search-ic { color: var(--state-error); }

/* ============================================================
   CARD .card — 应用卡片
   @anatomy
   <div class="card">
     <div class="ic"><svg class="icon">...</svg></div>
     <div class="title">Title</div>
     <div class="desc">Description text…</div>
     <div class="meta">meta info</div>
   </div>
   ============================================================ */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--card-foreground);
  cursor: pointer;
  transition: transform 160ms cubic-bezier(0.4, 0, 0.2, 1),
              border-color 160ms cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 160ms cubic-bezier(0.4, 0, 0.2, 1),
              background 160ms cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 200px;
}
.card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--border) 60%, var(--primary));
  box-shadow: var(--shadow-sm);
}
.card:active {
  transform: translateY(-1px);
  background: color-mix(in srgb, var(--card) 96%, #000000);
}
.card:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.card .ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--muted);
  color: var(--primary);
  margin-bottom: 8px;
  flex-shrink: 0;
}
.card .ic .icon { width: 20px; height: 20px; stroke-width: 1.7; }

.card .title {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--card-foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card .desc {
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--muted-foreground);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .meta {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--muted-foreground);
}

/* --- accented variant --- */
.card.accented {
  background: linear-gradient(135deg, var(--accent) 0%, var(--card) 60%);
  border-color: color-mix(in srgb, var(--primary) 20%, var(--border));
  border-left: 3px solid var(--primary);
}
.card.accented .title { color: var(--accent-foreground); }
.card.accented .ic { background: var(--accent); }

/* --- quiet variant --- */
.card.quiet {
  background: transparent;
  border: none;
  padding: 12px 0;
  border-radius: 0;
}
.card.quiet:hover {
  transform: none;
  box-shadow: none;
  background: var(--muted);
  border-radius: 10px;
  padding: 12px;
  margin: 0 -12px;
}
.card.quiet .title { font-size: 14px; font-weight: 500; color: var(--foreground); }
.card.quiet .ic { width: 28px; height: 28px; margin-bottom: 4px; }
.card.quiet .ic .icon { width: 16px; height: 16px; }

/* --- compact density --- */
.card.compact { padding: 12px; gap: 2px; }
.card.compact .ic { width: 28px; height: 28px; margin-bottom: 4px; }
.card.compact .ic .icon { width: 16px; height: 16px; }
.card.compact .title { font-size: 14px; font-weight: 500; }
.card.compact .desc,
.card.compact .meta { font-size: 12px; }

/* ============================================================
   RAIL .rail — 侧边栏导航
   @anatomy
   <nav class="rail">
     <div class="search-wrap"><div class="search">...</div></div>
     <div class="nav">
       <div class="section">
         <div class="section-label">LABEL</div>
         <a class="item active"><svg class="icon">...</svg><span>Home</span></a>
         <a class="item"><svg class="icon">...</svg><span>Chat</span><span class="dot"></span></a>
         <div class="item hist">
           <svg class="icon">...</svg><span>Item</span>
           <svg class="icon chev">...</svg>
           <div class="sub">
             <a class="item">Child</a>
             <a class="item active"><span class="dot"></span>Active Child</a>
           </div>
         </div>
       </div>
     </div>
     <div class="footer">
       <a class="item uav"><svg class="icon">...</svg><span>Utility</span></a>
       <div class="av">
         <div class="av-ic">U</div>
         <div class="av-info"><div class="av-name">Name</div><div class="av-email">email</div></div>
       </div>
     </div>
   </nav>
   ============================================================ */
.rail {
  display: flex;
  flex-direction: column;
  width: 240px;
  height: 100vh;
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
  font-family: var(--font-sans);
  color: var(--sidebar-foreground);
  overflow: hidden;
}
.rail .search-wrap {
  padding: 12px;
  flex-shrink: 0;
}
.rail .search-wrap .search {
  width: 100%;
  height: 36px;
  border-radius: 10px;
  background: var(--background);
  border-color: var(--border);
}
.rail .nav {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}
.rail .nav:hover { scrollbar-color: var(--border) transparent; }

.rail .section {
  margin-bottom: 16px;
}
.rail .section-label {
  padding: 8px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted-foreground);
  text-transform: none;
}
.rail .item {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  margin: 1px 0;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--sidebar-foreground);
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  transition: all 120ms cubic-bezier(0.4, 0, 0.2, 1);
}
.rail .item .icon {
  width: 18px;
  height: 18px;
  color: var(--muted-foreground);
  flex-shrink: 0;
  transition: color 120ms ease;
}
.rail .item > span:not(.sub-dot):not(.dot):not(.badge):not(.nav-badge) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sub-dot { width: 6px !important; height: 6px !important; min-width: 6px !important; max-width: 6px !important; min-height: 6px !important; max-height: 6px !important; flex: 0 0 6px !important; border-radius: 50% !important; }
.rail .item:hover {
  background: color-mix(in srgb, var(--sidebar-foreground) 6%, transparent);
}
.rail .item:hover .icon { color: var(--sidebar-foreground); }

.rail .item.active {
  background: var(--sidebar-accent);
  color: var(--sidebar-accent-foreground);
  font-weight: 500;
}
.rail .item.active .icon { color: var(--sidebar-primary); }
.rail .item.active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 16px;
  border-radius: 0 2px 2px 0;
  background: var(--sidebar-primary);
}
.rail .item.active:hover {
  background: color-mix(in srgb, var(--sidebar-accent) 80%, var(--sidebar-primary) 12%);
}

/* --- nested / history items --- */
.rail .item.hist {
  padding-right: 8px;
}
.rail .item.hist .chev {
  width: 14px;
  height: 14px;
  color: var(--muted-foreground);
  transition: transform 160ms cubic-bezier(0.4, 0, 0.2, 1);
}
.rail .item.hist.open .chev { transform: rotate(0deg); }
.rail .item.hist:not(.open) .chev { transform: rotate(-90deg); }
.rail .sub {
  overflow: hidden;
  max-height: 0;
  transition: max-height 200ms ease;
}
.rail .item.hist.open + .sub,
.rail .sub.open { max-height: 500px; }
.rail .sub .item {
  padding-left: 36px;
  font-size: 13px;
  color: var(--muted-foreground);
  height: 34px;
}
.rail .sub .item .dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--muted-foreground);
  flex-shrink: 0;
}
.rail .sub .item.active {
  background: transparent;
  color: var(--sidebar-primary);
  font-weight: 500;
}
.rail .sub .item.active .dot { background: var(--sidebar-primary); }
.rail .sub .item.active::before, .sidebar-sub-item::before, .sidebar-sub-item::after { display: none !important; content: none !important; }
.rail .sub .item:hover { color: var(--sidebar-foreground); }

/* --- badges --- */
.rail .item .badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--sidebar-primary);
  color: var(--primary-foreground);
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
}
.rail .item .badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--state-error);
  flex-shrink: 0;
}

/* --- footer / utility --- */
.rail .footer {
  flex-shrink: 0;
  padding: 8px;
  border-top: 1px solid var(--sidebar-border);
  margin-top: auto !important;
}
.rail .footer .item.uav {
  color: var(--muted-foreground);
}
.rail .footer .item.uav .icon { color: var(--muted-foreground); }
.rail .footer .item.uav:hover { background: color-mix(in srgb, var(--sidebar-foreground) 6%, transparent); }
.rail .footer .item.uav:hover .icon { color: var(--sidebar-foreground); }

.rail .av {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 120ms ease;
  margin-top: 4px;
}
.rail .av:hover { background: color-mix(in srgb, var(--sidebar-foreground) 6%, transparent); }
.rail .av-ic {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-foreground);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}
.rail .av-info { flex: 1; min-width: 0; }
.rail .av-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--sidebar-foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rail .av-email {
  font-size: 11px;
  color: var(--muted-foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   PANEL .panel — 数据表格面板
   @anatomy
   <div class="panel">
     <div class="head">
       <div class="head-title">Title</div>
       <div class="head-actions">...</div>
     </div>
     <table>
       <thead><tr><th class="cb"><input type="checkbox"></th><th>Name</th><th>Status</th><th class="metric">Users</th><th class="act"></th></tr></thead>
       <tbody>
         <tr class="sel">
           <td class="cb"><input type="checkbox" checked></td>
           <td><span class="txt-title">Value</span></td>
           <td><span class="status-chip ok">Running</span></td>
           <td class="metric"><span class="trend-up"><svg class="icon">...</svg>12,480</span></td>
           <td class="act"><button class="btn ghost sm icon-only">...</button></td>
         </tr>
       </tbody>
     </table>
   </div>
   ============================================================ */
.panel {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  overflow: hidden;
  font-family: var(--font-sans);
}
.panel .head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.panel .head-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--foreground);
}
.panel .head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.panel thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted-foreground);
  background: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  letter-spacing: 0;
}
.panel tbody td {
  padding: 12px 16px;
  text-align: left;
  color: var(--foreground);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  line-height: 1.5;
  vertical-align: middle;
  transition: background 120ms cubic-bezier(0.4, 0, 0.2, 1);
}
.panel tbody tr:last-child td { border-bottom: none; }
.panel tbody tr:hover td {
  background: color-mix(in srgb, var(--muted) 50%, transparent);
}
.panel tbody tr.sel td,
.panel tbody tr.selected td {
  background: color-mix(in srgb, var(--primary) 6%, var(--card));
}
.panel tbody tr.sel td:first-child,
.panel tbody tr.selected td:first-child {
  box-shadow: inset 2px 0 0 var(--primary);
}
.panel tbody tr.muted td {
  color: var(--muted-foreground);
  opacity: 0.7;
}

/* --- text cell variants --- */
.panel .txt-title { font-weight: 500; color: var(--foreground); }
.panel .txt-sec { color: var(--muted-foreground); font-size: 13px; }
.panel .txt-mono {
  font-family: var(--font-mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* --- checkbox column --- */
.panel th.cb,
.panel td.cb {
  width: 40px;
  padding-left: 16px;
  padding-right: 8px;
  text-align: center;
}
.panel td.cb input[type="checkbox"],
.panel th.cb input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* --- metric column (right-aligned mono) --- */
.panel th.metric,
.panel td.metric {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.panel .trend-up,
.panel .trend-down {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 500;
}
.panel .trend-up { color: var(--state-success); }
.panel .trend-down { color: var(--state-error); }
.panel .trend-up .icon,
.panel .trend-down .icon { width: 12px; height: 12px; }

/* --- status chips --- */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}
.status-chip::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex-shrink: 0;
}
.status-chip.ok::before { background: var(--state-success); }
.status-chip.run::before,
.status-chip.wait::before { background: var(--state-warning); }
.status-chip.err::before { background: var(--state-error); }
.status-chip.info::before { background: var(--state-info); }
.status-chip.off::before { background: var(--muted-foreground); }

/* pill variant */
.status-chip.pill {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
}
.status-chip.pill.ok { background: color-mix(in srgb, var(--state-success) 12%, transparent); color: var(--state-success); }
.status-chip.pill.run,
.status-chip.pill.wait { background: color-mix(in srgb, var(--state-warning) 12%, transparent); color: var(--state-warning); }
.status-chip.pill.err { background: color-mix(in srgb, var(--state-error) 12%, transparent); color: var(--state-error); }
.status-chip.pill.info { background: color-mix(in srgb, var(--state-info) 12%, transparent); color: var(--state-info); }

/* --- action column --- */
.panel th.act,
.panel td.act {
  text-align: right;
  width: 120px;
  white-space: nowrap;
}
.panel td.act {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

/* --- compact density --- */
.panel.compact thead th { padding: 8px 12px; }
.panel.compact tbody td { padding: 8px 12px; height: 36px; }
.panel.compact th.cb,
.panel.compact td.cb { padding-left: 12px; }

/* ============================================================
   COMPOSER .composer — 聊天输入器
   @anatomy
   <div class="composer">
     <div class="tools"><span class="composer-chip"><svg class="icon">...</svg> Tool running…</span></div>
     <textarea placeholder="输入消息…"></textarea>
     <div class="composer-foot">
       <div class="round">
         <button class="btn ghost sm icon-only"><svg class="icon">...</svg></button>
         <button class="btn ghost sm icon-only"><svg class="icon">...</svg></button>
       </div>
       <div class="spacer"></div>
       <div class="round">
         <button class="btn ghost sm icon-only voice"><svg class="icon">...</svg></button>
         <button class="btn primary sm icon-only send"><svg class="icon">...</svg></button>
       </div>
     </div>
   </div>
   ============================================================ */
.composer {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--background);
  box-shadow: 0 1px 3px rgba(14,17,21,0.06);
  font-family: var(--font-sans);
  transition: all 160ms cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}
.composer:focus-within {
  border-color: var(--primary);
  border-width: 1.5px;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent),
              0 2px 8px rgba(14,17,21,0.08);
}
.composer .tools {
  display: none;
  padding: 8px 12px 0;
}
.composer.has-tools .tools { display: block; }

.composer .composer-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 12px;
  line-height: 1;
}
.composer .composer-chip .icon { width: 14px; height: 14px; animation: spin 1.2s linear infinite; }

.composer textarea {
  width: 100%;
  min-height: 52px;
  max-height: 200px;
  padding: 14px 16px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.7;
  resize: none;
  overflow-y: auto;
  box-shadow: none;
}
.composer textarea::placeholder { color: var(--muted-foreground); }

.composer .composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 8px;
  gap: 4px;
}
.composer .round {
  display: flex;
  align-items: center;
  gap: 2px;
}
.composer .spacer { flex: 1; }

.composer .btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  padding: 0;
  border-radius: 999px;
  font-size: 14px;
}
.composer .btn .icon { width: 16px; height: 16px; }

.composer .send {
  background: var(--primary);
  color: var(--primary-foreground);
  border: none;
  opacity: 0.4;
  pointer-events: none;
  transition: all 120ms ease;
}
.composer.active .send,
.composer:focus-within:has(textarea:not(:placeholder-shown)) .send {
  opacity: 1;
  pointer-events: auto;
}
.composer .voice {
  color: var(--muted-foreground);
}

/* --- recording state --- */
.composer.recording {
  background: color-mix(in srgb, var(--destructive) 5%, var(--background));
  border-color: var(--destructive);
  border-width: 1.5px;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--destructive) 10%, transparent);
}
.composer.recording .voice {
  background: var(--destructive);
  color: var(--destructive-foreground);
}

/* --- disabled state --- */
.composer.disabled {
  background: var(--muted);
  border-color: var(--border);
  opacity: 0.7;
  box-shadow: none;
}
.composer.disabled textarea { cursor: not-allowed; }

/* --- single-line mode --- */
.composer.single-line {
  border-radius: 999px;
}
.composer.single-line textarea {
  min-height: 44px;
  max-height: 44px;
  padding: 0 16px;
  line-height: 44px;
  font-size: 14px;
}
.composer.single-line .composer-foot { display: none; }

/* --- animation keyframes --- */
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.5; transform: scale(1.2); }
}

/* ============================================================
   Preview layout helpers (non-component utilities)
   ============================================================ */
.preview-stack { display: flex; flex-direction: column; gap: 16px; max-width: 480px; }
.preview-row   { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.preview-grid  { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.preview-label { margin: 24px 0 8px; font-size: 12px; font-weight: 600; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: 0.04em; }
