/* Piko Cluster & Auto-Watch Studio v12 (2026-11-26)
   Faithful native macOS/iPadOS LocalBrowserClusterWindow + LocalBrowserClusterDesk +
   LocalBrowserClusterTile + LocalBrowserClusterWatchEditor + WebGL AgentEdgeLight.metal port.
   Zero scroll-hijack traps, crisp 1:1 Retina pixels, 60fps GPU composited, strict CSP. */

/* ============================================================================
   1. DESIGN TOKENS (Synced with Piko/Assets.xcassets & PikoTheme.swift)
   ============================================================================ */
.sx {
  --cs-ease: cubic-bezier(.22, 1, .36, 1);
  --cs-spring: cubic-bezier(.16, 1, .3, 1);
  --cs-canvas: #f5f5f3;
  --cs-surface: #fcfcfb;
  --cs-elevated: #efefed;
  --cs-page: #ffffff;
  --cs-page-soft: #f7f7f6;
  --cs-bub: #f0f0ee;
  --cs-line: rgba(17, 17, 16, .09);
  --cs-line-strong: rgba(17, 17, 16, .16);
  --cs-ink: #111110;
  --cs-on-ink: #ffffff;
  --cs-muted: #6e6e73;
  --cs-subtle: #8e8e93;
  --cs-rim: rgba(255, 255, 255, .92);
  --cs-stage-bg: radial-gradient(120% 90% at 50% 0%, rgba(17, 17, 16, .038), transparent 68%), linear-gradient(180deg, rgba(17, 17, 16, .02), rgba(17, 17, 16, .045));
  --cs-stage-border: rgba(17, 17, 16, .09);
  --cs-win-shadow:
    0 0 0 1px rgba(17, 17, 16, .09),
    0 24px 60px -18px rgba(17, 17, 16, .16),
    0 8px 20px -8px rgba(17, 17, 16, .08);
  --cs-pop-shadow:
    0 0 0 1px rgba(17, 17, 16, .1),
    0 22px 48px -12px rgba(17, 17, 16, .22),
    0 4px 12px rgba(17, 17, 16, .08);
  --cs-sheet-shadow:
    0 0 0 1px rgba(17, 17, 16, .1),
    0 32px 80px -16px rgba(17, 17, 16, .28);
  --cs-green: #16a34a;
  --cs-amber: #d97706;
  --cs-red: #dc2626;
}

:root[data-theme="dark"] .sx {
  --cs-canvas: #0b0b0a;
  --cs-surface: #151515;
  --cs-elevated: #1a1a19;
  --cs-page: #111110;
  --cs-page-soft: #171716;
  --cs-bub: #232322;
  --cs-line: rgba(255, 255, 255, .095);
  --cs-line-strong: rgba(255, 255, 255, .17);
  --cs-ink: #f4f4f4;
  --cs-on-ink: #111111;
  --cs-muted: #a1a1a6;
  --cs-subtle: #6e6e73;
  --cs-rim: rgba(255, 255, 255, .13);
  --cs-stage-bg: radial-gradient(90% 80% at 50% 0%, rgba(255, 255, 255, .055), transparent 64%), linear-gradient(180deg, rgba(255, 255, 255, .02), rgba(255, 255, 255, .005));
  --cs-stage-border: rgba(255, 255, 255, .1);
  --cs-win-shadow:
    0 0 0 1px rgba(255, 255, 255, .11),
    0 36px 90px -20px rgba(0, 0, 0, .82),
    0 10px 28px -8px rgba(0, 0, 0, .6),
    inset 0 1px 0 rgba(255, 255, 255, .09);
  --cs-pop-shadow:
    0 0 0 1px rgba(255, 255, 255, .14),
    0 24px 64px -10px rgba(0, 0, 0, .82);
  --cs-sheet-shadow:
    0 0 0 1px rgba(255, 255, 255, .14),
    0 36px 96px -12px rgba(0, 0, 0, .88);
  --cs-green: #34d399;
  --cs-amber: #fbbf24;
  --cs-red: #f87171;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sx {
    --cs-canvas: #0b0b0a;
    --cs-surface: #151515;
    --cs-elevated: #1a1a19;
    --cs-page: #111110;
    --cs-page-soft: #171716;
    --cs-bub: #232322;
    --cs-line: rgba(255, 255, 255, .095);
    --cs-line-strong: rgba(255, 255, 255, .17);
    --cs-ink: #f4f4f4;
    --cs-on-ink: #111111;
    --cs-muted: #a1a1a6;
    --cs-subtle: #6e6e73;
    --cs-rim: rgba(255, 255, 255, .13);
    --cs-stage-bg: radial-gradient(90% 80% at 50% 0%, rgba(255, 255, 255, .055), transparent 64%), linear-gradient(180deg, rgba(255, 255, 255, .02), rgba(255, 255, 255, .005));
    --cs-stage-border: rgba(255, 255, 255, .1);
    --cs-win-shadow:
      0 0 0 1px rgba(255, 255, 255, .11),
      0 36px 90px -20px rgba(0, 0, 0, .82),
      0 10px 28px -8px rgba(0, 0, 0, .6),
      inset 0 1px 0 rgba(255, 255, 255, .09);
    --cs-pop-shadow:
      0 0 0 1px rgba(255, 255, 255, .14),
      0 24px 64px -10px rgba(0, 0, 0, .82);
    --cs-sheet-shadow:
      0 0 0 1px rgba(255, 255, 255, .14),
      0 36px 96px -12px rgba(0, 0, 0, .88);
    --cs-green: #34d399;
    --cs-amber: #fbbf24;
    --cs-red: #f87171;
  }
}

/* ============================================================================
   2. ZERO SCROLL-DRAG SECTIONS (Replaces 240vh sticky scroll traps!)
   ============================================================================ */
.sx #cluster,
.sx #watch {
  height: auto !important;
  min-height: 0 !important;
  padding-block: clamp(44px, 5.5vw, 84px);
  overflow: visible;
  scroll-margin-top: 78px;
}

.sx #cluster .pin,
.sx #watch .pin,
.sx #cluster .cs-inner,
.sx #watch .cs-inner {
  position: static !important;
  height: auto !important;
  min-height: 0 !important;
  display: block !important;
  padding: 0 !important;
  overflow: visible !important;
  grid-template-columns: none !important;
  grid-template-rows: none !important;
}

.sx #cluster .sx-way,
.sx #watch .sx-way {
  min-height: 40px;
  margin-bottom: clamp(10px, 1.4vw, 16px) !important;
  width: min(100% - 2 * max(var(--page-padding, 28px), env(safe-area-inset-left)), 1240px) !important;
  margin-inline: auto !important;
  display: flex !important;
  align-items: center;
}

/* Editorial showcase header: dramatic display type + active chapter readout */
.sx .cs-wrap {
  width: min(100% - 2 * max(var(--page-padding, 28px), env(safe-area-inset-left)), 1240px);
  margin: 0 auto;
}

.sx .cs-head {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, .88fr);
  gap: clamp(16px, 2.8vw, 44px);
  align-items: end;
  margin-bottom: clamp(16px, 2vw, 24px);
}

.sx .cs-head .sx-eyebrow {
  margin-bottom: 8px;
  font-size: 11.5px;
  font-weight: 560;
  letter-spacing: .08em;
  color: var(--cs-muted);
}

.sx .cs-head h2 {
  font-size: clamp(28px, 3.3vw, 44px);
  font-weight: 640;
  line-height: 1.1;
  letter-spacing: -.048em;
  color: var(--cs-ink);
  transition: opacity .26s ease;
}

html[lang="en"] .sx .cs-head h2 {
  letter-spacing: -.032em;
  line-height: 1.08;
}

.sx .cs-head-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: flex-start;
}

.sx .cs-lead {
  font-size: clamp(13.5px, 1.15vw, 15px);
  line-height: 1.75;
  color: var(--cs-muted);
  max-width: 44ch;
  min-height: 3.5em;
  transition: opacity .24s ease;
}

/* Interactive Chapter Hairline Tabs (instant jump + live progress, zero pill bubbles) */
.sx .cs-chapters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 22px;
  width: 100%;
  border-bottom: 1px solid var(--cs-line);
}

.sx .cs-chap {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 4px 0 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--cs-muted);
  font-size: 13px;
  font-weight: 520;
  cursor: pointer;
  overflow: visible;
  transition: color .18s ease;
}

.sx .cs-chap:hover {
  color: var(--cs-ink);
}

.sx .cs-chap em {
  font-style: normal;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 600;
  opacity: .52;
}

.sx .cs-chap .cs-chap-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: transparent;
  pointer-events: none;
}

.sx .cs-chap .cs-chap-bar i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--cs-ink);
  transform-origin: left center;
  transform: scaleX(0);
  will-change: transform;
}

.sx .cs-chap[aria-pressed="true"] {
  color: var(--cs-ink);
  font-weight: 600;
}

.sx .cs-chap[aria-pressed="true"] em {
  opacity: .9;
}

.sx .cs-playbtn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-bottom: 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--cs-muted);
  cursor: pointer;
  transition: color .18s ease, background-color .18s ease, transform .15s ease;
}

.sx .cs-playbtn:hover {
  background: var(--cs-elevated);
  color: var(--cs-ink);
}

.sx .cs-playbtn:active {
  transform: scale(.94);
}

.sx .cs-playbtn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Hide legacy .caps overlay nodes while preserving DOM fallback for SR/SEO */
.sx #cluster .caps,
.sx #watch .caps {
  display: none !important;
}

/* ============================================================================
   3. DIRECT STAGE CONTAINER (Zero outer wrapper card — window sits on canvas)
   ============================================================================ */
.sx #cl-stage,
.sx #wt-stage {
  position: relative !important;
  width: min(100% - 2 * max(var(--page-padding, 28px), env(safe-area-inset-left)), 1240px) !important;
  margin: 0 auto !important;
  min-height: 0 !important;
  opacity: 1 !important;
  transform: none !important;
}

/* ============================================================================
   4. AUTHENTIC NATIVE MACOS CLUSTER WINDOW (LocalBrowserClusterWindow.swift)
   ============================================================================ */
.sx .cw2 {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 576px;
  border-radius: 16px;
  background: var(--cs-canvas);
  box-shadow: var(--cs-win-shadow);
  overflow: hidden;
  color: var(--cs-ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "PingFang TC", "Helvetica Neue", sans-serif;
  font-size: 13px;
  line-height: 1.48;
  text-align: left;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

.sx .cw2.is-lab {
  height: 604px;
}

/* --- macOS Titlebar + Cluster Toolbar (48px) --- */
.sx .cw2-tb {
  position: relative;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 10px 0 16px;
  background: var(--cs-surface);
  border-bottom: 1px solid var(--cs-line);
  flex: none;
}

.sx .cw2-lights {
  display: flex;
  align-items: center;
  gap: 7.5px;
  flex: none;
}

.sx .cw2-lights i {
  width: 11.5px;
  height: 11.5px;
  border-radius: 50%;
  display: block;
  box-shadow: inset 0 0 0 .5px rgba(0, 0, 0, .18);
}

.sx .cw2-lights i:nth-child(1) { background: #ff5f57; }
.sx .cw2-lights i:nth-child(2) { background: #febc2e; }
.sx .cw2-lights i:nth-child(3) { background: #28c840; }

.sx .cw2-cluster-pick {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 0 8px;
  margin-left: 4px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--cs-ink);
  white-space: nowrap;
  cursor: default;
}

.sx .cw2-cluster-pick b {
  font-size: 13.5px;
  font-weight: 620;
  letter-spacing: -.01em;
}

.sx .cw2-cluster-count {
  font-size: 11.5px;
  color: var(--cs-muted);
  white-space: nowrap;
}

.sx .cw2-spacer {
  flex: 1;
  min-width: 8px;
}

/* Lab scenario segmented control */
.sx .cw2-seg {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--cs-ink) 6%, transparent);
  border: 0;
}

.sx .cw2-seg button {
  border: 0;
  background: transparent;
  color: var(--cs-muted);
  border-radius: 7px;
  min-height: 28px;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 540;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .16s ease, color .16s ease, box-shadow .16s ease;
}

.sx .cw2-seg button:hover {
  color: var(--cs-ink);
}

.sx .cw2-seg button[aria-pressed="true"] {
  background: var(--cs-surface);
  color: var(--cs-ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .14);
}

/* Toolbar icon buttons (BrowserClusterToolbarLabel.swift: 36px hit, inputCorner 10px, badge capsule) */
.sx .cw2-tools {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}

.sx .cw2-tbtn {
  position: relative;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--cs-ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color .15s ease, transform .12s ease;
}

.sx .cw2-tbtn:hover {
  background: color-mix(in srgb, var(--cs-elevated) 80%, transparent);
}

.sx .cw2-tbtn:active {
  transform: scale(.93);
}

.sx .cw2-tbtn.is-on {
  background: var(--cs-elevated);
  box-shadow: inset 0 0 0 1px var(--cs-line);
}

.sx .cw2-tbtn .cw2-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--cs-ink);
  color: var(--cs-on-ink);
  font-size: 9.5px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.sx .cw2-tbtn .cw2-badge.is-show {
  display: inline-flex;
  animation: cs-pop .32s var(--cs-spring);
}

/* --- Main Split Body: Browser Canvas (left) + Agent Desk (right 324px) --- */
.sx .cw2-body {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 324px;
  transition: grid-template-columns .3s var(--cs-ease);
}

.sx .cw2.desk-hidden .cw2-body {
  grid-template-columns: minmax(0, 1fr) 0px;
}

.sx .cw2.desk-hidden .cw2-desk {
  opacity: 0;
  pointer-events: none;
  border-left-color: transparent;
}

/* --- Browser Canvas Area --- */
.sx .cw2-canvas {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--cs-canvas);
  overflow: hidden;
}

/* Compact / tablet tile tab switcher (flat hairline tabs, zero boxed bar) */
.sx .cw2-tabs {
  display: none;
  gap: 12px;
  padding: 0 2px;
  border-radius: 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--cs-line);
  flex: none;
}

.sx .cw2-tab {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 4px 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--cs-muted);
  font-size: 11.5px;
  font-weight: 520;
  cursor: pointer;
  transition: color .18s ease;
}

.sx .cw2-tab span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sx .cw2-tab i.cw2-tab-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cs-subtle);
  flex: none;
  transition: background-color .2s ease, box-shadow .2s ease;
}

.sx .cw2-tab.is-live i.cw2-tab-dot {
  background: #33c7ff;
  box-shadow: 0 0 8px rgba(51, 199, 255, .85);
}

.sx .cw2-tab.is-alert i.cw2-tab-dot {
  background: var(--cs-amber);
  box-shadow: 0 0 8px rgba(251, 191, 36, .75);
}

.sx .cw2-tab[aria-selected="true"] {
  background: transparent;
  color: var(--cs-ink);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--cs-ink);
}

.sx .cw2-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

/* Expanded single-tile focus mode (model.toggleFocus) */
.sx .cw2.has-focus .cw2-grid {
  grid-template-columns: minmax(0, 1fr);
}

.sx .cw2.has-focus .cw2-tile:not(.is-focused) {
  display: none;
}

/* ============================================================================
   5. AUTHENTIC BROWSER TILE (LocalBrowserClusterTile.swift)
   ============================================================================ */
.sx .cw2-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-radius: 14px;
  background: var(--cs-page);
  box-shadow: 0 0 0 1px var(--cs-line), 0 2px 10px rgba(0, 0, 0, .06);
  overflow: hidden;
  transition: box-shadow .24s ease, transform .24s var(--cs-ease);
}

.sx .cw2-tile.is-mine {
  box-shadow: 0 0 0 1.5px var(--cs-ink), 0 10px 26px rgba(0, 0, 0, .14);
}

.sx .cw2-tile.is-held {
  cursor: pointer;
}

/* --- Tile Operation Bar (42px, PikoTheme.surface) --- */
.sx .tile-bar {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 0 6px 0 10px;
  background: var(--cs-surface);
  border-bottom: 1px solid var(--cs-line);
  flex: none;
}

.sx .tile-st-ic {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  color: var(--cs-ink);
  flex: none;
  transition: background-color .2s ease, color .2s ease;
}

.sx .cw2-tile.is-busy .tile-st-ic {
  background: color-mix(in srgb, var(--cs-ink) 9%, transparent);
}

.sx .cw2-tile.is-alert .tile-st-ic {
  color: var(--cs-amber);
}

.sx .tile-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.24;
}

.sx .tile-title {
  font-size: 11.5px;
  font-weight: 620;
  color: var(--cs-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sx .tile-status {
  font-size: 10.5px;
  color: var(--cs-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sx .cw2-tile.is-alert .tile-status {
  color: var(--cs-amber);
  font-weight: 550;
}

.sx .tile-acts {
  display: flex;
  align-items: center;
  gap: 1px;
  flex: none;
}

.sx .tile-btn {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--cs-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease, transform .12s ease;
}

.sx .tile-btn:hover {
  background: var(--cs-elevated);
  color: var(--cs-ink);
}

.sx .tile-btn:active {
  transform: scale(.92);
}

.sx .tile-btn.btn-take {
  display: none;
  color: var(--cs-ink);
}

.sx .cw2-tile.is-held .tile-btn.btn-take {
  display: grid;
}

/* --- Subtle Mini Browser URL Strip inside tile --- */
.sx .tile-url {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 10px;
  background: var(--cs-page-soft);
  border-bottom: 1px solid var(--cs-line);
  font-size: 10.5px;
  color: var(--cs-muted);
  flex: none;
}

.sx .tile-url .url-lock {
  width: 10px;
  height: 10px;
  opacity: .55;
  flex: none;
}

.sx .tile-url .url-host {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10px;
  letter-spacing: -.01em;
}

.sx .tile-url .url-pill {
  padding: 0;
  border-radius: 0;
  background: transparent;
  font-size: 9.5px;
  font-weight: 560;
  color: var(--cs-muted);
  white-space: nowrap;
}

.sx .tile-url .url-pill.is-live {
  background: transparent;
  color: var(--cs-green);
}

.sx .tile-url .url-pill.is-warn {
  background: transparent;
  color: var(--cs-amber);
}

/* --- Realistic Webpage Viewport inside Tile --- */
.sx .tile-web {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 11px 12px 11px;
  gap: 7px;
  background: var(--cs-page);
}

/* Realistic web app header inside tile */
.sx .web-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.sx .web-brand-l {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.sx .web-mark {
  width: 15px;
  height: 15px;
  border-radius: 0;
  background: transparent;
  border: 0;
  display: grid;
  place-items: center;
  color: var(--cs-muted);
  flex: none;
}

.sx .web-brand h4 {
  font-size: 12.5px;
  font-weight: 660;
  letter-spacing: -.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sx .web-tag {
  font-size: 10px;
  font-weight: 520;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--cs-muted);
  white-space: nowrap;
}

/* Realistic search bar + action button */
.sx .web-search-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sx .web-input {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0 9px;
  border-radius: 8px;
  border: 1px solid var(--cs-line);
  background: var(--cs-page-soft);
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--cs-muted);
  transition: border-color .18s ease, box-shadow .18s ease, color .18s ease;
}

.sx .web-input.is-filled {
  color: var(--cs-ink);
  border-color: var(--cs-line-strong);
}

.sx .web-input.is-typing {
  border-color: color-mix(in srgb, var(--cs-ink) 40%, transparent);
}

.sx .web-input .web-q {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sx .web-input:not(.is-filled) .web-q:empty::before {
  content: attr(data-ph);
  color: var(--cs-subtle);
}

.sx .web-input.is-typing .web-q::after {
  content: "";
  display: inline-block;
  width: 1.5px;
  height: 12px;
  background: var(--cs-ink);
  vertical-align: -2px;
  margin-left: 1px;
  animation: cs-blink .9s step-end infinite;
}

.sx .web-go {
  flex: none;
  height: 30px;
  padding: 0 11px;
  border-radius: 8px;
  border: 0;
  background: var(--cs-elevated);
  color: var(--cs-ink);
  font-size: 11px;
  font-weight: 580;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .12s ease, background-color .15s ease, color .15s ease;
}

.sx .web-go.is-press {
  transform: scale(.91);
  background: var(--cs-ink);
  color: var(--cs-on-ink);
}

/* Inline filter labels (no pill boxes) */
.sx .web-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.sx .web-chip {
  font-size: 10px;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--cs-subtle);
  border: 0;
  transition: color .2s ease;
}

.sx .web-chip.is-on {
  color: var(--cs-ink);
  font-weight: 580;
}

/* Hairline result rows (SwiftUI native flat list — zero boxed-row clutter) */
.sx .web-list {
  list-style: none;
  margin: 2px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 0 1 auto;
  min-height: 0;
  overflow: visible;
}

.sx .web-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 2px;
  border-radius: 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--cs-line);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .28s ease, transform .34s var(--cs-ease), background-color .24s ease, color .24s ease, border-color .24s ease;
}

.sx .web-row:last-child,
.sx .web-row:has(+ .is-pick) {
  border-bottom-color: transparent;
}

.sx .web-row.is-on {
  opacity: 1;
  transform: none;
}

.sx .web-row.is-pick {
  margin: 2px -6px;
  padding: 7px 8px;
  border-radius: 9px;
  background: var(--cs-ink);
  color: var(--cs-on-ink);
  border-bottom-color: transparent;
}

.sx .web-row-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sx .web-row-main strong {
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sx .web-row-main small {
  font-size: 10px;
  color: var(--cs-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sx .web-row.is-pick .web-row-main small {
  color: color-mix(in srgb, var(--cs-on-ink) 74%, transparent);
}

.sx .web-row-val {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.sx .web-row-val b {
  font-size: 12px;
  font-weight: 660;
  white-space: nowrap;
}

.sx .web-row-val span {
  font-size: 9.5px;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--cs-subtle);
  white-space: nowrap;
}

.sx .web-row.is-pick .web-row-val span {
  background: transparent;
  color: color-mix(in srgb, var(--cs-on-ink) 78%, transparent);
}

/* Skeleton placeholder before results populate */
.sx .web-skel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
  transition: opacity .22s ease;
}

.sx .web-skel.is-hide {
  display: none;
}

.sx .web-skel i {
  display: block;
  height: 32px;
  border-radius: 7px;
  background: linear-gradient(90deg, var(--cs-page-soft) 0%, var(--cs-elevated) 50%, var(--cs-page-soft) 100%);
  background-size: 200% 100%;
  border: 0;
  animation: cs-shimmer 1.8s ease-in-out infinite;
}

.sx .web-skel i:nth-child(2) { animation-delay: .18s; opacity: .78; }
.sx .web-skel i:nth-child(3) { animation-delay: .36s; opacity: .52; }

/* Hairline contextual footer inside each browser tile (no nested box) */
.sx .web-detail {
  margin-top: auto;
  padding: 9px 0 1px;
  border-radius: 0;
  border: 0;
  border-top: 1px solid var(--cs-line);
  background: transparent;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: none;
  opacity: .55;
  transition: opacity .3s ease, border-color .3s ease;
}

.sx .web-detail.is-lit {
  opacity: 1;
  border-top-color: var(--cs-line-strong);
  background: transparent;
}

.sx .web-detail-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--cs-ink);
}

.sx .web-detail-top span {
  font-size: 9.5px;
  font-weight: 520;
  color: var(--cs-muted);
  white-space: nowrap;
}

.sx .web-detail-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 4px;
}

.sx .web-detail-bar i {
  flex: 1;
  height: 100%;
  border-radius: 999px;
  background: var(--cs-line);
}

.sx .web-detail-bar i.is-hi {
  background: var(--cs-ink);
}

.sx .web-detail-sub {
  font-size: 10px;
  color: var(--cs-muted);
  line-height: 1.4;
}

/* Watch channel summary hairline inside Watch tiles */
.sx .watch-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 2px 0 7px;
  border-radius: 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--cs-line);
  font-size: 10px;
  color: var(--cs-muted);
}

.sx .watch-meta-row b {
  color: var(--cs-ink);
  font-weight: 580;
}

/* --- Auto-Watch Messaging Viewport inside Tile --- */
.sx .watch-stream {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  overflow: hidden;
  padding-top: 2px;
}

.sx .watch-quiet {
  margin: auto 0;
  padding: 12px 6px;
  border-radius: 0;
  border: 0;
  background: transparent;
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 5px;
}

.sx .watch-quiet.is-on {
  display: flex;
}

.sx .watch-radar {
  position: relative;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--cs-ink);
}

.sx .watch-radar::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid var(--cs-ink);
  opacity: .26;
  animation: cs-radar 2.4s ease-out infinite;
}

.sx .watch-quiet b {
  font-size: 11px;
  font-weight: 600;
}

.sx .watch-quiet span {
  font-size: 10px;
  color: var(--cs-muted);
}

.sx .wbub {
  display: none;
  flex-direction: column;
  gap: 3px;
  max-width: 92%;
}

.sx .wbub.is-on {
  display: flex;
  animation: cs-msg-in .32s var(--cs-ease);
}

.sx .wbub.is-in {
  align-self: flex-start;
}

.sx .wbub.is-out {
  align-self: flex-end;
  align-items: flex-end;
}

.sx .wbub-who {
  font-size: 9.5px;
  color: var(--cs-subtle);
  padding: 0 4px;
}

.sx .wbub-body {
  padding: 7px 10px;
  border-radius: 12px;
  font-size: 11px;
  line-height: 1.48;
}

.sx .wbub.is-in .wbub-body {
  background: var(--cs-bub);
  color: var(--cs-ink);
  border-bottom-left-radius: 4px;
}

.sx .wbub.is-out .wbub-body {
  background: var(--cs-ink);
  color: var(--cs-on-ink);
  border-bottom-right-radius: 4px;
}

.sx .wbub.is-draft .wbub-body {
  background: var(--cs-elevated);
  color: var(--cs-ink);
  border: 1px dashed var(--cs-line-strong);
}

.sx .wbub-crm {
  display: none;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
  padding: 0;
  border-radius: 0;
  border: 0;
  background: transparent;
  font-size: 9.5px;
  font-weight: 540;
  color: var(--cs-muted);
}

.sx .wbub-crm.is-on {
  display: inline-flex;
  animation: cs-pop .32s var(--cs-spring);
}

.sx .watch-gap {
  display: none;
  align-self: center;
  padding: 2px 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  font-size: 9.5px;
  color: var(--cs-muted);
}

.sx .watch-gap.is-on {
  display: inline-flex;
}

/* Out-of-rule Human Escalation Banner (clean accent hairline, zero nested box) */
.sx .watch-esc {
  display: none;
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  border-radius: 0;
  background: color-mix(in srgb, var(--cs-amber) 8%, transparent);
  border: 0;
  border-left: 2px solid var(--cs-amber);
  font-size: 10.5px;
  line-height: 1.38;
  color: var(--cs-ink);
}

.sx .watch-esc.is-on {
  display: flex;
  animation: cs-msg-in .32s var(--cs-ease);
}

.sx .watch-esc svg {
  color: var(--cs-amber);
  flex: none;
}

.sx .watch-esc b {
  font-weight: 640;
}

.sx .watch-comp {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 4px;
}

/* Offline auto-reconnect overlay with backoff ring (3s -> 6s -> 12s) */
.sx .tile-off {
  position: absolute;
  inset: 44px 0 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 16px;
  text-align: center;
  background: color-mix(in srgb, var(--cs-page) 86%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .26s ease;
}

.sx .cw2-tile.is-offline .tile-off {
  opacity: 1;
}

.sx .off-ring {
  position: relative;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
}

.sx .off-ring svg.ring-track {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.sx .off-ring circle {
  fill: none;
  stroke-width: 2.2;
}

.sx .off-ring circle.bg {
  stroke: var(--cs-line-strong);
}

.sx .off-ring circle.fg {
  stroke: var(--cs-ink);
  stroke-linecap: round;
  stroke-dasharray: 113.1;
  stroke-dashoffset: 38;
  animation: cs-spin 1.8s linear infinite;
}

.sx .tile-off b {
  font-size: 12.5px;
  font-weight: 640;
}

.sx .tile-off .off-sub {
  font-size: 10.5px;
  color: var(--cs-muted);
}

.sx .off-steps {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.sx .off-steps span {
  font-size: 9.5px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--cs-elevated);
  color: var(--cs-muted);
  border: 1px solid var(--cs-line);
}

.sx .off-steps span.is-now {
  background: var(--cs-ink);
  color: var(--cs-on-ink);
  border-color: var(--cs-ink);
  font-weight: 620;
}

/* ============================================================================
   6. WEBGL AGENT EDGE LIGHT CANVAS + AUTHENTIC TAKEOVER GATE + POINTER MARK
   ============================================================================ */
.sx .tile-glow {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 7;
  overflow: hidden;
}

.sx .tile-glow canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Authentic AgentTakeoverGate (AgentTakeoverGate.swift: covers page below tile-bar,
   dim 0.5 black + "AI 正在控制 / 长按接管" -> "松开接管" + 140x5 capsule progress) */
.sx .tile-gate {
  position: absolute;
  inset: 44px 0 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 16px;
  text-align: center;
  background: rgba(0, 0, 0, .54);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  color: #ffffff;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
}

.sx .tile-gate.is-on {
  opacity: 1;
}

.sx .tile-gate b {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -.01em;
}

.sx .tile-gate span {
  font-size: 11.5px;
  opacity: .88;
}

.sx .tile-gate .gate-track {
  width: 128px;
  height: 5px;
  margin-top: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .24);
  overflow: hidden;
  opacity: 0;
  transition: opacity .16s ease;
}

.sx .tile-gate.is-press .gate-track,
.sx .tile-gate.is-scrub .gate-track {
  opacity: 1;
}

.sx .tile-gate .gate-fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: #ffffff;
  transform-origin: left center;
  transform: scaleX(0);
  will-change: transform;
}

/* "You are in control" bottom floating pill inside tile */
.sx .tile-you {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 5px 5px 10px;
  border-radius: 12px;
  background: var(--cs-ink);
  color: var(--cs-on-ink);
  font-size: 11px;
  font-weight: 540;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .28);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity .22s ease, transform .28s var(--cs-spring);
}

.sx .tile-you span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sx .tile-back {
  border: 0;
  border-radius: 8px;
  min-height: 26px;
  padding: 0 10px;
  background: var(--cs-on-ink);
  color: var(--cs-ink);
  font-size: 11px;
  font-weight: 640;
  cursor: pointer;
  flex: none;
  transition: transform .12s ease;
}

.sx .tile-back:active {
  transform: scale(.94);
}

.sx .cw2-tile.is-mine .tile-you {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* Authentic PikoAgentPointerMark (PikoAgentPointer.swift + BrowserPointerGlyph.swift) */
.sx .tile-ptr {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 8;
  width: 26px;
  height: 26px;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(50%, 50%, 0);
  transition: opacity .2s ease;
  will-change: transform, opacity;
}

.sx .tile-ptr.is-on {
  opacity: 1;
}

/* Soft rotating spectrum bloom behind pointer */
.sx .tile-ptr .ptr-bloom {
  position: absolute;
  left: -4px;
  top: -4px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: conic-gradient(#33c7ff, #5c73ff, #a85cff, #ff4db8, #ff8c40, #ffd640, #4de685, #33c7ff);
  filter: blur(7px);
  opacity: .72;
  animation: cs-spin 3s linear infinite;
}

.sx .tile-ptr svg.ptr-glyph {
  position: relative;
  z-index: 2;
  width: 24px;
  height: 24px;
  display: block;
  overflow: visible;
  transform-origin: 3px 2.5px;
  transition: transform .1s var(--cs-ease);
}

.sx .tile-ptr.is-tap svg.ptr-glyph {
  transform: scale(.84);
}

/* Authentic BrowserPointerClickFeedback: 30pt ripple scale 0.5 -> 1.6 */
.sx .tile-ptr .ptr-ripple {
  position: absolute;
  left: -12px;
  top: -12.5px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, var(--cs-ink) 55%, transparent);
  background: rgba(255, 255, 255, .28);
  opacity: 0;
  transform: scale(.5);
}

.sx .tile-ptr.is-tap .ptr-ripple {
  animation: cs-ripple .42s var(--cs-ease);
}

/* Window-level User Cursor (for scripted Approval & Takeover demo) */
.sx .cw2-uptr {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 22;
  width: 22px;
  height: 22px;
  pointer-events: none;
  opacity: 0;
  will-change: transform, opacity;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .34));
  transition: opacity .2s ease;
}

.sx .cw2-uptr.is-on {
  opacity: 1;
}

.sx .cw2-uptr svg {
  width: 100%;
  height: 100%;
  display: block;
  transform-origin: 3px 2.5px;
  transition: transform .1s ease;
}

.sx .cw2-uptr.is-tap svg {
  transform: scale(.84);
}

/* ============================================================================
   7. AUTHENTIC RIGHT AGENT DESK (LocalBrowserClusterDesk.swift)
   ============================================================================ */
.sx .cw2-desk {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--cs-surface);
  border-left: 1px solid var(--cs-line);
  transition: opacity .22s ease;
}

/* Desk Top Row: Avatar + ChatPicker (主代理) + AgentStrip + Scope + Menu */
.sx .desk-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 10px 14px;
  border-bottom: 1px solid var(--cs-line);
  flex: none;
}

.sx .desk-ava {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: contain;
  transform: rotate(-4deg);
  flex: none;
}

.sx .desk-id {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.sx .desk-title-row {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.sx .desk-title-row b {
  font-size: 13px;
  font-weight: 620;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sx .desk-role {
  font-size: 10.5px;
  color: var(--cs-muted);
  white-space: nowrap;
}

.sx .desk-sub {
  font-size: 11px;
  color: var(--cs-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 14px;
}

.sx .desk-icons {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}

.sx .desk-ibtn {
  position: relative;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--cs-ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color .15s ease;
}

.sx .desk-ibtn:hover,
.sx .desk-ibtn[aria-expanded="true"] {
  background: var(--cs-elevated);
}

.sx .desk-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 6.5px;
  height: 6.5px;
  border-radius: 50%;
  background: var(--cs-ink);
  box-shadow: 0 0 0 2px var(--cs-surface);
  opacity: 0;
  transform: scale(.4);
  transition: opacity .2s ease, transform .24s var(--cs-spring);
}

.sx .desk-dot.is-on {
  opacity: 1;
  transform: scale(1);
}

/* BrowserClusterLiveActivity Strip ("3 个窗口在工作 · 1 项需要你 >") */
.sx .desk-live {
  display: none;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 38px;
  padding: 6px 14px;
  border: 0;
  border-bottom: 1px solid var(--cs-line);
  background: color-mix(in srgb, var(--cs-elevated) 55%, var(--cs-surface));
  color: var(--cs-ink);
  font-size: 11.5px;
  font-weight: 540;
  text-align: left;
  cursor: pointer;
  flex: none;
  transition: background-color .15s ease;
}

.sx .desk-live.is-on {
  display: flex;
}

.sx .desk-live:hover {
  background: var(--cs-elevated);
}

.sx .desk-live .live-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #33c7ff;
  box-shadow: 0 0 8px rgba(51, 199, 255, .85);
  flex: none;
  animation: cs-pulse 1.6s ease-in-out infinite;
}

.sx .desk-live.is-alert .live-pulse {
  background: var(--cs-amber);
  box-shadow: 0 0 8px rgba(251, 191, 36, .8);
}

.sx .desk-live .live-txt {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sx .desk-live .live-chev {
  color: var(--cs-muted);
  flex: none;
}

/* Desk Popover (Sub-Agent Roster / Live Activity Details) */
.sx .desk-pop {
  position: absolute;
  top: 52px;
  right: 10px;
  z-index: 16;
  width: min(296px, calc(100% - 20px));
  padding: 10px;
  border-radius: 14px;
  background: var(--cs-surface);
  box-shadow: var(--cs-pop-shadow);
  opacity: 0;
  transform: translateY(-6px) scale(.98);
  pointer-events: none;
  transition: opacity .18s ease, transform .22s var(--cs-spring);
}

.sx .desk-pop.is-open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.sx .desk-pop-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px 8px;
  border-bottom: 1px solid var(--cs-line);
  margin-bottom: 4px;
}

.sx .desk-pop-h b {
  font-size: 12.5px;
  font-weight: 640;
}

.sx .desk-pop-x {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: var(--cs-elevated);
  color: var(--cs-ink);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.sx .desk-pop-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 6px;
  border-radius: 9px;
}

.sx .desk-pop-row + .desk-pop-row {
  border-top: 1px solid var(--cs-line);
  border-radius: 0;
}

.sx .desk-pop-row > div {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.28;
}

.sx .desk-pop-row strong {
  font-size: 11.5px;
  font-weight: 600;
}

.sx .desk-pop-row small {
  font-size: 10.5px;
  color: var(--cs-muted);
}

.sx .desk-pop-act {
  border: 0;
  border-radius: 7px;
  height: 26px;
  padding: 0 8px;
  background: var(--cs-elevated);
  color: var(--cs-ink);
  font-size: 10.5px;
  font-weight: 560;
  cursor: pointer;
}

/* Chat Transcript Area */
.sx .desk-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  scrollbar-width: thin;
}

.sx .dm {
  display: none;
}

.sx .dm.is-on {
  display: flex;
  animation: cs-msg-in .32s var(--cs-ease);
}

.sx .dm.is-user {
  justify-content: flex-end;
}

.sx .dm.is-user p {
  max-width: 88%;
  padding: 9px 13px;
  border-radius: 16px;
  border-bottom-right-radius: 5px;
  background: var(--cs-ink);
  color: var(--cs-on-ink);
  font-size: 12px;
  line-height: 1.54;
}

.sx .dm.is-piko {
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  line-height: 1.58;
}

.sx .dm-status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--cs-muted);
}

.sx .dm.is-piko:not(.is-working) .dm-status {
  display: none;
}

.sx .dm-dots {
  display: inline-flex;
  gap: 3px;
}

.sx .dm-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--cs-ink);
  animation: cs-breath 1.2s infinite;
}

.sx .dm-dots i:nth-child(2) { animation-delay: .16s; }
.sx .dm-dots i:nth-child(3) { animation-delay: .32s; }

.sx .dm-mem {
  display: none;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  font-size: 11px;
  font-weight: 520;
  color: var(--cs-muted);
}

.sx .dm-mem.is-on {
  display: inline-flex;
  animation: cs-msg-in .3s var(--cs-ease);
}

.sx .dm-reply {
  display: none;
}

.sx .dm-reply.is-on {
  display: block;
}

/* Clean inline Goal checklist inside Desk Chat (no nested box) */
.sx .dm-goal {
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 2px 0 2px 11px;
  border-radius: 0;
  border: 0;
  border-left: 2px solid var(--cs-line-strong);
  background: transparent;
}

.sx .dm-goal.is-on {
  display: flex;
  animation: cs-msg-in .36s var(--cs-ease);
}

.sx .dm-goal-h {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 620;
}

.sx .dm-goal-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .26s ease, transform .3s var(--cs-ease);
}

.sx .dm-goal-step.is-on {
  opacity: 1;
  transform: none;
}

.sx .dm-goal-step i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid var(--cs-ink);
  flex: none;
}

/* Inline CRM / Watch notice inside Desk Chat (left accent hairline, no nested box) */
.sx .dm-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 2px 0 2px 11px;
  border-radius: 0;
  border: 0;
  border-left: 2px solid var(--cs-line-strong);
  background: transparent;
  font-size: 11.5px;
  line-height: 1.5;
}

.sx .dm-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 620;
}

.sx .dm-card-pill {
  display: inline-flex;
  align-self: flex-start;
  padding: 0;
  border-radius: 0;
  border: 0;
  font-size: 10.5px;
  font-weight: 540;
  color: var(--cs-muted);
}

.sx .dm-card.is-warn {
  border-left-color: var(--cs-amber);
  background: transparent;
}

.sx .dm-card.is-warn .dm-card-head svg {
  color: var(--cs-amber);
}

/* Quick prompt suggestions in #lab (borderless soft tint) */
.sx .desk-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 0 12px 6px;
  flex: none;
}

.sx .desk-prompt {
  border: 0;
  border-radius: 7px;
  background: color-mix(in srgb, var(--cs-ink) 5%, transparent);
  color: var(--cs-muted);
  font-size: 10.5px;
  padding: 4px 8px;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}

.sx .desk-prompt:hover {
  background: color-mix(in srgb, var(--cs-ink) 10%, transparent);
  color: var(--cs-ink);
}

/* Floating Rounded Composer */
.sx .desk-comp {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 12px 12px;
  min-height: 44px;
  padding: 4px 5px 4px 12px;
  border-radius: 20px;
  background: var(--cs-page);
  border: 1px solid var(--cs-line);
  flex: none;
}

.sx .desk-in {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  outline: 0;
  font: inherit;
  font-size: 12px;
  color: var(--cs-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sx span.desk-in:empty::before {
  content: attr(data-ph);
  color: var(--cs-subtle);
}

.sx .desk-comp.is-typing span.desk-in::after {
  content: "";
  display: inline-block;
  width: 1.5px;
  height: 14px;
  background: var(--cs-ink);
  vertical-align: -2px;
  margin-left: 1px;
  animation: cs-blink .9s step-end infinite;
}

.sx .desk-in::placeholder {
  color: var(--cs-subtle);
}

.sx .desk-send {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: var(--cs-elevated);
  color: var(--cs-muted);
  display: grid;
  place-items: center;
  flex: none;
  cursor: pointer;
  transition: background-color .18s ease, color .18s ease, transform .12s ease;
}

.sx .desk-send.is-ready,
.sx .desk-send.is-stop {
  background: var(--cs-ink);
  color: var(--cs-on-ink);
}

.sx .desk-send:active {
  transform: scale(.93);
}

/* ============================================================================
   8. NATIVE SHEETS: PikoApprovalHost & LocalBrowserClusterWatchEditor
   ============================================================================ */
.sx .cw2-shade {
  position: absolute;
  inset: 0;
  z-index: 18;
  background: rgba(0, 0, 0, .38);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

.sx .cw2.is-asking .cw2-shade,
.sx .cw2.is-editing-watch .cw2-shade {
  opacity: 1;
  pointer-events: auto;
}

.sx .cw2-sheet {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 20;
  width: min(370px, calc(100% - 28px));
  padding: 18px 18px 14px;
  border-radius: 20px;
  background: var(--cs-surface);
  box-shadow: var(--cs-sheet-shadow);
  opacity: 0;
  transform: translate(-50%, -46%) scale(.97);
  pointer-events: none;
  transition: opacity .2s ease, transform .26s var(--cs-spring);
}

.sx .cw2.is-asking .cw2-sheet.sheet-approve {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

.sx .cw2.is-editing-watch .cw2-sheet.sheet-watch {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
  width: min(452px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  padding: 15px 16px 13px;
  overflow-y: auto;
}

.sx .sh2-h {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sx .sh2-h b {
  flex: 1;
  font-size: 14.5px;
  font-weight: 640;
}

.sx .sh2-x {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--cs-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}

.sx .sh2-x:hover {
  background: var(--cs-elevated);
  color: var(--cs-ink);
}

.sx .sh2-p {
  margin-top: 9px;
  font-size: 12px;
  color: var(--cs-muted);
  line-height: 1.6;
}

.sx .sh2-box {
  margin-top: 12px;
  padding: 10px 0 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  border-top: 1px solid var(--cs-line);
  font-size: 11.5px;
  line-height: 1.6;
}

.sx .sh2-box strong {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 620;
  margin-bottom: 3px;
}

.sx .sh2-ok {
  display: block;
  width: 100%;
  margin-top: 14px;
  min-height: 40px;
  border: 0;
  border-radius: 999px;
  background: var(--cs-ink);
  color: var(--cs-on-ink);
  font-size: 13px;
  font-weight: 620;
  cursor: pointer;
  transition: transform .14s ease, opacity .15s ease;
}

.sx .sh2-ok:active {
  transform: scale(.97);
}

.sx .sh2-row {
  display: flex;
  margin-top: 4px;
}

.sx .sh2-row button {
  flex: 1;
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--cs-ink);
  font-size: 12px;
  font-weight: 540;
  cursor: pointer;
}

.sx .sh2-row .sh2-more {
  color: var(--cs-muted);
  cursor: default;
}

/* Watch Editor hairline sections (single grouping layer inside sheet) */
.sx .we-sec {
  margin-top: 12px;
  padding: 12px 0 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  border-top: 1px solid var(--cs-line);
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.sx .we-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--cs-muted);
}

.sx .we-seg {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--cs-elevated);
}

.sx .we-seg button {
  border: 0;
  border-radius: 8px;
  min-height: 30px;
  padding: 0 6px;
  background: transparent;
  color: var(--cs-muted);
  font-size: 11.5px;
  font-weight: 560;
  cursor: pointer;
  transition: background-color .16s ease, color .16s ease;
}

.sx .we-seg button[aria-pressed="true"] {
  background: var(--cs-surface);
  color: var(--cs-ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
}

.sx .we-note {
  font-size: 11px;
  color: var(--cs-muted);
  line-height: 1.5;
}

.sx .we-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}

.sx .we-switch {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  border: 0;
  background: var(--cs-line-strong);
  cursor: pointer;
  transition: background-color .18s ease;
  flex: none;
}

.sx .we-switch::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .18s var(--cs-spring);
}

.sx .we-switch[aria-checked="true"] {
  background: var(--cs-ink);
}

:root[data-theme="dark"] .sx .we-switch[aria-checked="true"]::after {
  background: #0b0b0a;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sx .we-switch[aria-checked="true"]::after {
    background: #0b0b0a;
  }
}

.sx .we-switch[aria-checked="true"]::after {
  transform: translateX(16px);
}

.sx .we-slider {
  width: 100%;
  accent-color: var(--cs-ink);
  cursor: pointer;
}

/* ============================================================================
   9. LAB SECTION POLISH (#lab)
   ============================================================================ */
.sx #lab {
  padding-block: clamp(64px, 8vw, 118px);
}

.sx #lab .sx-rv {
  opacity: 1 !important;
  transform: none !important;
}

.sx #lab .lab-head {
  margin-bottom: 24px;
}

.sx #lab .note {
  margin-top: 12px;
  font-size: 11.5px;
  color: var(--cs-muted);
}

/* ============================================================================
   11. RESPONSIVE MULTI-DEVICE ASPECT-RATIO ADAPTATION
   ============================================================================ */
/* Medium Desktop / iPad Landscape (<= 1120px): tighten right desk */
@media (max-width: 1120px) {
  .sx .cw2-body {
    grid-template-columns: minmax(0, 1fr) 292px;
  }
  .sx .cw2-grid {
    gap: 8px;
  }
}

/* iPad Portrait / Tablet (<= 960px): tabbed tile focus + right desk */
@media (max-width: 960px) {
  .sx .cs-head {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }
  .sx .cs-lead {
    min-height: 0;
  }
  .sx .cw2 {
    height: 590px;
  }
  .sx .cw2.is-lab {
    height: 620px;
  }
  .sx .cw2-tabs {
    display: flex;
  }
  .sx .cw2-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .sx .cw2-tile:not(.is-tab-active) {
    display: none;
  }
  .sx .cw2-tools .tbtn-hide-md {
    display: none;
  }
}

/* Compact / iPhone Portrait (<= 720px): single tile top + docked Agent Desk below */
@media (max-width: 720px) {
  .sx #cluster,
  .sx #watch {
    padding-block: 48px;
  }
  .sx .cs-wrap,
  .sx #cl-stage,
  .sx #wt-stage,
  .sx #cluster .sx-way,
  .sx #watch .sx-way {
    width: calc(100% - 28px) !important;
  }
  .sx .cw2,
  .sx .cw2.is-lab {
    height: auto;
    min-height: 620px;
    border-radius: 14px;
  }
  .sx .cw2-tb {
    flex-wrap: wrap;
    height: auto;
    padding: 8px 10px;
    gap: 6px;
  }
  .sx .cw2-lights {
    display: none;
  }
  .sx .cw2-cluster-pick {
    margin-left: 0;
    padding-left: 2px;
  }
  .sx .cw2-seg {
    order: 5;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .sx .cw2-seg button {
    padding: 0 6px;
    font-size: 11.5px;
  }
  .sx .cw2-body {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: 378px 268px;
  }
  .sx .cw2.desk-hidden .cw2-body {
    grid-template-rows: 420px 0px;
  }
  .sx .web-detail {
    display: none;
  }
  .sx .cw2-desk {
    border-left: 0;
    border-top: 1px solid var(--cs-line);
  }
  .sx .cw2-canvas {
    padding: 8px;
    gap: 8px;
  }
  .sx .desk-head {
    padding: 8px 10px;
  }
  .sx .desk-log {
    padding: 10px 12px 6px;
  }
  .sx .desk-comp {
    margin: 4px 10px 10px;
    min-height: 42px;
  }
  .sx .cs-chapters {
    gap: 0 14px;
  }
  .sx .cs-chap {
    min-height: 36px;
    padding: 4px 0 9px;
    font-size: 12px;
  }
}

/* iPhone Landscape / Short Wide Screens (<= 460px height) */
@media (max-height: 460px) and (min-width: 600px) {
  .sx .cw2,
  .sx .cw2.is-lab {
    height: 460px;
  }
  .sx .cw2-body {
    grid-template-columns: minmax(0, 1fr) 260px;
  }
}

/* Reduced Motion / Motion Paused */
@media (prefers-reduced-motion: reduce) {
  .sx .tile-ptr .ptr-bloom,
  .sx .watch-radar::before,
  .sx .off-ring circle.fg,
  .sx .desk-live .live-pulse,
  .sx .web-skel i {
    animation: none !important;
  }
}

:root[data-motion="paused"] .sx .tile-ptr .ptr-bloom,
:root[data-motion="paused"] .sx .watch-radar::before,
:root[data-motion="paused"] .sx .off-ring circle.fg,
:root[data-motion="paused"] .sx .desk-live .live-pulse,
:root[data-motion="paused"] .sx .web-skel i {
  animation: none !important;
}

/* Focus visible rings */
.sx .cs-chap:focus-visible,
.sx .cs-playbtn:focus-visible,
.sx .cs-act:focus-visible,
.sx .cw2 button:focus-visible {
  outline: 2px solid var(--cs-ink);
  outline-offset: 2px;
}

/* ============================================================================
   12. KEYFRAMES
   ============================================================================ */
@keyframes cs-spin {
  to { transform: rotate(360deg); }
}

@keyframes cs-blink {
  50% { opacity: 0; }
}

@keyframes cs-breath {
  50% { opacity: .24; }
}

@keyframes cs-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: .65; }
}

@keyframes cs-radar {
  0% { transform: scale(.7); opacity: .55; }
  100% { transform: scale(1.65); opacity: 0; }
}

@keyframes cs-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes cs-msg-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: none; }
}

@keyframes cs-pop {
  from { opacity: 0; transform: scale(.78); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes cs-ripple {
  0% { opacity: .8; transform: scale(.5); }
  100% { opacity: 0; transform: scale(1.65); }
}
