/* ==================== Infinite Canvas Hub & Studio (DESIGN.md v3.1) ==================== */

/* ---------- 1. Canvas Management Hub (/canvas) ---------- */
.cv-hub-page {
  position: relative;
}

.cv-hub-container {
  padding-top: 56px;
  padding-bottom: 64px;
}

.cv-hub-hero {
  padding-bottom: 18px;
}

.cv-hub-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.cv-hub-toolbar .tools-tabs {
  margin-bottom: 0;
}

.cv-hub-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.cv-search-box {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  min-width: 210px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  background: var(--bg-surface);
  border: 1px solid var(--line);
  color: var(--fg-3);
  transition: border-color var(--dur-fast) var(--ease-standard);
}

.cv-search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
}

.cv-search-box input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  outline: none;
  color: var(--fg);
  font-size: var(--fs-sm);
  width: 150px;
}

.cv-sort-select {
  width: auto;
  min-width: 120px;
  height: 36px;
  padding: 0 28px 0 12px;
  font-size: var(--fs-sm);
  flex: 0 0 auto;
  cursor: pointer;
}

.cv-hub-controls .btn {
  height: 36px;
  white-space: nowrap;
  flex: 0 0 auto;
}

.cv-batch-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 16px;
  background: var(--bg-subtle);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  color: var(--fg);
}

.cv-batch-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cv-hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.cv-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--line-hairline);
  border-radius: var(--r-lg);
  overflow: visible;
  box-shadow: none;
  transition: border-color var(--dur-fast) var(--ease-standard), transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}

.cv-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
}

.cv-card:has(.pop.is-open) {
  z-index: 20;
}

.cv-card.is-checked {
  border-color: var(--accent);
}

.cv-card-check {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--r-xs);
  background: var(--bg-glass-strong);
  border: 1px solid var(--line);
  cursor: pointer;
}

.cv-card-media-link {
  position: relative;
  display: block;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  overflow: hidden;
  background: var(--bg-subtle);
}

.cv-card-cover {
  width: 100%;
  aspect-ratio: 16 / 10;
  display: block;
}

.cv-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cv-card-cover--empty {
  position: relative;
  display: grid;
  place-items: center;
  background: var(--bg-subtle);
}

.cv-card-empty-dots {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, var(--line-strong) 1px, transparent 1px);
  background-size: 16px 16px;
  opacity: .55;
}

.cv-card-empty-ic {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  background: var(--bg-surface);
  border: 1px solid var(--line-hairline);
  display: grid;
  place-items: center;
  color: var(--fg-3);
}

.cv-card-pin-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 26px;
  height: 26px;
  border-radius: var(--r-full);
  background: var(--bg-glass-strong);
  border: 1px solid var(--line-hairline);
  display: grid;
  place-items: center;
  color: var(--accent-text);
}

.cv-card-body {
  padding: 12px 14px 14px;
  display: grid;
  gap: 4px;
}

.cv-card-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cv-card-title {
  flex: 1;
  min-width: 0;
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  color: var(--fg);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cv-card-title:hover {
  color: var(--accent-text);
}

.cv-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  color: var(--fg-3);
}

.cv-hub-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 52px 24px;
  background: var(--bg-surface);
  border: 1px solid var(--line-hairline);
  border-radius: var(--r-lg);
  color: var(--fg-2);
}

.cv-hub-empty p {
  margin: 0;
  max-width: 440px;
  font-size: var(--fs-sm);
}

.cv-empty-tpl-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.cv-guest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.cv-guest-card {
  background: var(--bg-surface);
  border: 1px solid var(--line-hairline);
  border-radius: var(--r-lg);
  padding: 18px;
  display: grid;
  gap: 8px;
}

.cv-guest-card h3 {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  color: var(--fg);
}

.cv-guest-card p {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--fg-2);
  line-height: var(--lh-normal);
}

.cv-guest-ic {
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  background: var(--bg-subtle);
  color: var(--fg);
  display: grid;
  place-items: center;
}

/* Modals shared between Hub and Studio */
dialog.modal.cv-hub-modal {
  width: min(540px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  margin: auto;
  border: 1px solid var(--line-hairline);
  border-radius: var(--r-xl);
  background: var(--bg-elevated);
  color: var(--fg);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}

dialog.modal.cv-hub-modal[open] {
  display: flex;
  flex-direction: column;
}

.cv-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-hairline);
  background: var(--bg-elevated);
}

.cv-modal-head b {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  color: var(--fg);
}

.cv-modal-body {
  padding: 18px 20px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  background: var(--bg-elevated);
}

.cv-hub-modal .field-label {
  display: block;
  margin-bottom: 8px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--fg-2);
}

.cv-hub-modal .input {
  width: 100%;
  box-sizing: border-box;
}

.cv-modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 16px;
  margin-top: 18px;
  border-top: 1px solid var(--line-hairline);
}

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

.cv-tpl-card {
  display: grid;
  gap: 4px;
  text-align: left;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--bg-surface);
  border: 1px solid var(--line-hairline);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-standard), background var(--dur-fast) var(--ease-standard);
}

.cv-tpl-card:hover {
  border-color: var(--line-strong);
  background: var(--bg-hover);
}

.cv-tpl-card.is-selected {
  background: var(--bg-active);
  border-color: var(--accent);
}

.cv-tpl-ic {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  background: var(--bg-subtle);
  display: grid;
  place-items: center;
  color: var(--fg);
  margin-bottom: 4px;
}

.cv-tpl-card strong {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--fg);
}

.cv-tpl-card small {
  font-size: var(--fs-xs);
  color: var(--fg-2);
  line-height: var(--lh-snug);
}

.cv-check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-sm);
  color: var(--fg-2);
  cursor: pointer;
}

/* ---------- 2. Full-Screen Canvas Studio (/canvas/{id}) ---------- */
body.page-canvas-studio {
  overflow: hidden;
  background: var(--bg-canvas);
}

.cv-studio {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-canvas);
  user-select: none;
}

/* Top Floating Bars */
.cv-head-left {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 6px;
  background: var(--bg-glass-strong);
  backdrop-filter: blur(20px);
  border: 1px solid var(--line-hairline);
  border-radius: var(--r-full);
  box-shadow: var(--shadow-pop);
  max-width: calc(100vw - 380px);
}

.cv-brand-mark {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.cv-brand-mark .logo-wordmark .logo-img {
  width: auto;
  height: 20px;
}

.cv-head-sep {
  width: 1px;
  height: 16px;
  background: var(--line-hairline);
  margin: 0 2px;
}

.cv-proj-pop {
  min-width: 0;
}

.cv-proj-trigger {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--fg);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  min-width: 0;
  max-width: 190px;
}

.cv-proj-trigger:hover {
  background: var(--bg-hover);
}

.cv-proj-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cv-recent-list {
  max-height: 220px;
}

.cv-head-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--r-full);
  background: transparent;
  color: var(--fg-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  cursor: pointer;
  white-space: nowrap;
}

.cv-head-pill-btn:hover {
  background: var(--bg-hover);
  color: var(--fg);
}

.cv-head-pill-btn[aria-pressed="true"] {
  background: var(--bg-active);
  color: var(--fg);
  font-weight: var(--fw-semibold);
}

.cv-save-status {
  font-size: var(--fs-xs);
  color: var(--fg-3);
  padding: 0 6px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.cv-head-right {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cv-head-right .shell-utility {
  position: static;
}

.cv-head-island {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  background: var(--bg-glass-strong);
  backdrop-filter: blur(20px);
  border: 1px solid var(--line-hairline);
  border-radius: var(--r-full);
  box-shadow: var(--shadow-pop);
}

.cv-jump-panel {
  width: 260px;
  padding: 8px;
}

.cv-jump-list {
  margin-top: 6px;
  max-height: 240px;
}

.cv-jump-empty {
  padding: 14px 10px;
  text-align: center;
  font-size: var(--fs-xs);
  color: var(--fg-3);
}

/* Left Vertical Tool Rail */
.cv-tool-rail {
  position: fixed;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 35;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  background: var(--bg-glass-strong);
  backdrop-filter: blur(20px);
  border: 1px solid var(--line-hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
}

.cv-rail-btn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--fg-2);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard);
}

.cv-rail-btn:hover {
  background: var(--bg-hover);
  color: var(--fg);
}

.cv-rail-btn.is-active {
  background: var(--bg-active);
  color: var(--fg);
}

.cv-rail-sep {
  width: 20px;
  height: 1px;
  background: var(--line-hairline);
  margin: 2px 0;
}

/* Left Expandable Drawer (Assets / Layers) */
.cv-side-drawer {
  position: fixed;
  top: 68px;
  left: 68px;
  bottom: 68px;
  width: 280px;
  z-index: 34;
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--line-hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}

.cv-side-drawer[hidden] {
  display: none;
}

.cv-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-hairline);
}

.cv-drawer-body {
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cv-drawer-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.cv-drawer-section-label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--fg-2);
}

.cv-drawer-asset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.cv-drawer-asset-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
  border-radius: var(--r-sm);
  background: var(--bg-subtle);
  border: 1px solid transparent;
  cursor: pointer;
  text-align: left;
}

.cv-drawer-asset-card:hover {
  border-color: var(--line-strong);
}

.cv-drawer-asset-card img,
.cv-drawer-asset-card video {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--r-xs);
  display: block;
}

.cv-drawer-asset-audio {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--r-xs);
  background: var(--bg-surface);
  border: 1px solid var(--line-hairline);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--fg-2);
}

.cv-drawer-asset-audio small {
  font-size: var(--fs-2xs);
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}

.cv-drawer-asset-card span {
  font-size: var(--fs-xs);
  color: var(--fg-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cv-layers-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cv-layer-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: var(--r-sm);
  background: transparent;
}

.cv-layer-row:hover {
  background: var(--bg-hover);
}

.cv-layer-row.is-selected {
  background: var(--bg-active);
}

.cv-layer-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--fg);
  font-size: var(--fs-xs);
  text-align: left;
  cursor: pointer;
  padding: 4px 2px;
}

.cv-layer-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Infinite Viewport & World */
.cv-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  outline: none;
  touch-action: none;
}

.cv-viewport.is-space-pan,
.cv-viewport.is-panning {
  cursor: grab;
}

.cv-viewport.is-panning {
  cursor: grabbing;
}

.cv-viewport.is-drop-active::after {
  content: "";
  position: absolute;
  inset: 14px;
  border: 2px dashed var(--accent);
  border-radius: var(--r-lg);
  background: var(--accent-weak);
  pointer-events: none;
  z-index: 30;
}

.cv-grid-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-color: var(--bg-canvas);
  background-image: radial-gradient(circle, rgba(0, 0, 0, 0.11) 1.1px, transparent 1.1px);
  background-size: var(--grid-step, 24px) var(--grid-step, 24px);
  background-position: var(--grid-x, 0px) var(--grid-y, 0px);
}

[data-theme="dark"] .cv-grid-bg {
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.11) 1.1px, transparent 1.1px);
}

.cv-viewport.is-plain-bg .cv-grid-bg {
  background-image: none;
}

.cv-world {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.cv-edges-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  overflow: visible;
  pointer-events: none;
  z-index: 2;
  color: var(--line-strong);
}

.cv-edge {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 1.75;
  pointer-events: stroke;
  cursor: pointer;
  transition: stroke var(--dur-fast) var(--ease-standard);
}

.cv-edge:hover,
.cv-edge.is-active {
  stroke: var(--accent);
  stroke-width: 2.25;
}

.cv-edge-draft {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 6 4;
}

.cv-nodes-layer {
  position: absolute;
  top: 0;
  left: 0;
}

.cv-guides-layer {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 999;
}

.cv-guide {
  position: absolute;
  background: var(--accent);
  opacity: 0.7;
}

.cv-guide.is-v {
  top: -8000px;
  width: 1px;
  height: 16000px;
}

.cv-guide.is-h {
  left: -8000px;
  height: 1px;
  width: 16000px;
}

/* Marquee & Empty State */
.cv-marquee {
  position: absolute;
  border: 1px solid var(--accent);
  background: var(--accent-weak);
  pointer-events: none;
  z-index: 25;
}

.cv-empty-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 10;
  padding: 20px;
}

.cv-empty-hint[hidden] {
  display: none;
}

.cv-empty-card {
  pointer-events: auto;
  max-width: 480px;
  padding: 24px;
  text-align: center;
  background: var(--bg-glass-strong);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line-hairline);
  border-radius: var(--r-xl);
}

.cv-empty-card h3 {
  margin: 0 0 6px;
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  color: var(--fg);
}

.cv-empty-card p {
  margin: 0 0 16px;
  font-size: var(--fs-sm);
  color: var(--fg-2);
}

.cv-empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

/* ---------- 3. Canvas Nodes ---------- */
.cv-node {
  position: absolute;
  top: 0;
  left: 0;
  box-sizing: border-box;
  border-radius: var(--r-md);
  border: 1.5px solid transparent;
  cursor: move;
  transition: border-color var(--dur-instant) var(--ease-standard);
}

.cv-viewport.is-dragging-node .cv-node {
  transition: none;
}

.cv-node.is-culled > .cv-node-surface {
  visibility: hidden;
}

.cv-node.is-selected {
  border-color: var(--accent);
}

.cv-node-chip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  color: var(--fg-2);
  pointer-events: auto;
}

.cv-node-chip-ic {
  display: inline-flex;
  align-items: center;
  color: var(--fg-3);
  flex-shrink: 0;
}

.cv-node-chip-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: var(--fw-medium);
}

.cv-node-title-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  outline: none;
  color: var(--fg-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  padding: 2px 4px;
  border-radius: var(--r-xs);
}

.cv-node-title-input:focus {
  background: var(--bg-surface);
  color: var(--fg);
}

.cv-node-mini-btn {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--fg-3);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.cv-node-mini-btn:hover {
  background: var(--bg-active);
  color: var(--fg);
}

.cv-node-surface {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: var(--r-md);
  background: var(--bg-surface);
  border: 1px solid var(--line-hairline);
  overflow: hidden;
  box-shadow: none;
}

.cv-node-surface--media .cv-node-bh,
.cv-node-surface--media .cv-node-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cv-node-surface--video {
  background: #101116;
}

.cv-node-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.cv-node-surface--audio {
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}

.cv-node-audio {
  width: 100%;
  height: 36px;
}

.cv-node-audio-note {
  font-size: var(--fs-xs);
  color: var(--fg-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cv-node-surface--text {
  padding: 12px 14px;
  background: var(--bg-subtle);
  display: flex;
  flex-direction: column;
}

.cv-text-area {
  flex: 1;
  width: 100%;
  border: 0;
  background: transparent;
  outline: none;
  resize: none;
  color: var(--fg);
  font-size: var(--fs-sm);
  line-height: var(--lh-normal);
  font-family: var(--font);
  cursor: text;
}

.cv-text-area--note {
  padding: 12px;
  height: 100%;
}

.cv-text-streaming {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-top: 6px;
  font-size: var(--fs-xs);
  color: var(--accent-text);
}

/* Frame & Shape */
.cv-node--frame {
  border: 1.5px dashed var(--line-strong);
  background: transparent;
}

.cv-node--frame.is-selected {
  border-style: solid;
  border-color: var(--accent);
}

.cv-frame-head {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cv-frame-dim {
  font-size: var(--fs-xs);
  color: var(--fg-3);
}

.cv-frame-body {
  width: 100%;
  height: 100%;
}

.cv-shape-box {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Generator Placeholder Node on Canvas */
.cv-node-chip-spec {
  font-size: var(--fs-2xs);
  color: var(--fg-3);
  padding: 1px 6px;
  border-radius: var(--r-xs);
  background: var(--bg-subtle);
  border: 1px solid var(--line-hairline);
  white-space: nowrap;
  flex-shrink: 0;
}

.cv-node-surface--gen-placeholder {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--bg-surface);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-standard), background var(--dur-fast) var(--ease-standard);
}

.cv-node--generator:hover .cv-node-surface--gen-placeholder {
  border-color: var(--line-strong);
}

.cv-node--generator.is-selected .cv-node-surface--gen-placeholder {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
}

.cv-gen-ph-center {
  display: grid;
  place-items: center;
  flex: 1;
  min-height: 0;
}

.cv-gen-ph-ic {
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  border: 1px solid var(--line-hairline);
  display: grid;
  place-items: center;
  color: var(--fg-3);
}

.cv-gen-ph-ic .i {
  width: 22px;
  height: 22px;
}

.cv-gen-ph-prompt {
  width: 100%;
  margin-top: auto;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  background: var(--bg-subtle);
  color: var(--fg-2);
  font-size: var(--fs-xs);
  line-height: var(--lh-snug);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

/* Detached Viewport-Level Generator Composer Card */
.cv-gen-composer {
  position: fixed;
  z-index: 42;
  width: min(580px, calc(100vw - 32px));
  background: var(--bg-elevated);
  border: 1px solid var(--line-hairline);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-pop);
  padding: 12px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cv-gen-composer[hidden] {
  display: none;
}

.cv-gc-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 28px;
}

.cv-gc-refs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.cv-gc-frames-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cv-gc-slot-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  border: 1px dashed var(--line-strong);
  background: var(--bg-subtle);
  color: var(--fg-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color var(--dur-fast) var(--ease-standard), background var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard);
}

.cv-gc-slot-btn:hover {
  border-color: var(--accent-line);
  background: var(--bg-hover);
  color: var(--fg);
}

.cv-gc-slot-btn span {
  font-size: var(--fs-xs);
  line-height: 1;
}

.cv-gc-swap-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: var(--fg-3);
}

.cv-gc-ref-thumb {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-hairline);
  background: var(--bg-subtle);
  overflow: visible;
  flex-shrink: 0;
}

.cv-gc-ref-pick {
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: inherit;
  overflow: hidden;
  cursor: pointer;
  display: block;
}

.cv-gc-ref-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: calc(var(--r-md) - 1px);
  display: block;
}

.cv-gc-ref-tag {
  position: absolute;
  left: 2px;
  bottom: 2px;
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--bg-glass-strong);
  border: 1px solid var(--line-hairline);
  color: var(--fg);
  font-size: var(--fs-2xs);
  line-height: 1.1;
  pointer-events: none;
}

.cv-gc-ref-rm {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  color: var(--fg-2);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-standard);
}

.cv-gc-ref-thumb:hover .cv-gc-ref-rm,
.cv-gc-ref-thumb:focus-within .cv-gc-ref-rm {
  opacity: 1;
}

.cv-gc-top-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  align-self: flex-start;
}

.cv-gc-input {
  width: 100%;
}

.cv-gc-textarea {
  width: 100%;
  min-height: 44px;
  max-height: 128px;
  border: 0;
  padding: 2px 2px;
  background: transparent;
  color: var(--fg);
  font-family: var(--font);
  font-size: var(--fs-sm);
  line-height: var(--lh-normal);
  resize: none;
  outline: none;
}

.cv-gc-textarea::placeholder {
  color: var(--fg-3);
}

.cv-gc-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--line-hairline);
}

.cv-gc-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.cv-gc-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  max-width: 100%;
  padding: 0 9px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--fg);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard);
}

.cv-gc-chip:hover {
  background: var(--bg-hover);
}

.cv-gc-chip.icon-only {
  width: 30px;
  padding: 0;
  justify-content: center;
  color: var(--fg-2);
}

.cv-gc-chip.is-model {
  max-width: 185px;
}

.cv-gen-chip-lbl {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.cv-gen-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.cv-gen-brand img {
  width: 15px;
  height: 15px;
  object-fit: contain;
  display: block;
}

.cv-gen-chev {
  color: var(--fg-3);
  flex-shrink: 0;
  margin-left: 1px;
}

.cv-gc-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.cv-gc-quote {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-xs);
  color: var(--fg-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cv-gc-quote .credit-star {
  width: 13px;
  height: 13px;
}

.cv-gc-send {
  width: 34px;
  height: 34px;
}

/* Viewport-level Generator Popover Host (outside CSS transform) */
.pop-panel.cv-gen-popover {
  position: fixed;
  z-index: 65;
  width: 344px;
  max-width: calc(100vw - 24px);
  padding: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--line-hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transform: none;
  opacity: 1;
  visibility: visible;
}

.pop-panel.cv-gen-popover[hidden] {
  display: none;
}

.cv-gen-pop-head {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--fg-2);
  padding: 2px 4px 6px;
  border-bottom: 1px solid var(--line-hairline);
}

.cv-gen-pop-list,
.cv-gen-param-host {
  display: grid;
  gap: 4px;
  max-height: 316px;
  overflow-y: auto;
  padding-right: 2px;
}

.cv-gen-pop-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--fg);
  text-align: left;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard);
}

.cv-gen-pop-item:hover {
  background: var(--bg-hover);
}

.cv-gen-pop-item.is-selected {
  background: var(--bg-subtle);
  border-color: var(--accent-line);
}

.cv-gen-pop-thumb {
  width: 32px;
  height: 32px;
  border-radius: var(--r-xs);
  object-fit: cover;
  flex-shrink: 0;
}

.cv-gen-pop-thumb.is-media {
  display: grid;
  place-items: center;
  background: var(--bg-subtle);
  border: 1px solid var(--line-hairline);
  color: var(--fg-2);
}

.cv-gen-pop-main {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}

.cv-gen-pop-main strong {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cv-gen-pop-main small {
  font-size: var(--fs-2xs);
  color: var(--fg-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cv-gen-check {
  color: var(--accent-text);
  flex-shrink: 0;
}

/* Task progress overlay inside node */
.cv-task-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  background: var(--bg-glass-strong);
  backdrop-filter: blur(8px);
  z-index: 4;
}

.cv-task-overlay.is-error {
  color: var(--danger);
  text-align: center;
}

.cv-task-overlay.is-error p {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--fg-2);
}

.cv-task-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--r-full);
  background: var(--bg-surface);
  border: 1px solid var(--line-hairline);
  font-size: var(--fs-xs);
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

.cv-task-bar {
  width: 68%;
  height: 4px;
  border-radius: var(--r-full);
  background: var(--bg-muted);
  overflow: hidden;
}

.cv-task-bar-fill {
  height: 100%;
  background: var(--accent);
  transition: width var(--dur-base) var(--ease-standard);
}

.cv-spinner {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  animation: cv-spin 0.8s linear infinite;
}

@keyframes cv-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Resize handles & '+' branch button */
.cv-resize-handles {
  display: none;
}

.cv-node.is-selected:not(.is-locked) .cv-resize-handles {
  display: block;
}

.cv-rh {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1.5px solid var(--accent);
  z-index: 6;
}

.cv-rh.is-nw { top: -5px; left: -5px; cursor: nwse-resize; }
.cv-rh.is-n  { top: -5px; left: calc(50% - 4.5px); cursor: ns-resize; }
.cv-rh.is-ne { top: -5px; right: -5px; cursor: nesw-resize; }
.cv-rh.is-e  { top: calc(50% - 4.5px); right: -5px; cursor: ew-resize; }
.cv-rh.is-se { bottom: -5px; right: -5px; cursor: nwse-resize; }
.cv-rh.is-s  { bottom: -5px; left: calc(50% - 4.5px); cursor: ns-resize; }
.cv-rh.is-sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.cv-rh.is-w  { top: calc(50% - 4.5px); left: -5px; cursor: ew-resize; }

.cv-branch-plus {
  position: absolute;
  top: 50%;
  right: -34px;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  color: var(--fg-2);
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard);
  z-index: 7;
}

.cv-node:hover .cv-branch-plus,
.cv-node.is-selected .cv-branch-plus {
  opacity: 1;
}

.cv-branch-plus:hover {
  border-color: var(--accent);
  color: var(--accent-text);
}

/* ---------- 4. Floating Context Action Bar ---------- */
.cv-context-bar {
  position: fixed;
  z-index: 38;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  background: var(--bg-glass-strong);
  backdrop-filter: blur(22px);
  border: 1px solid var(--line-hairline);
  border-radius: var(--r-full);
  box-shadow: var(--shadow-pop);
  max-width: calc(100vw - 32px);
  overflow-x: auto;
  scrollbar-width: none;
}

.cv-context-bar[hidden] {
  display: none;
}

.cv-ctx-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 9px;
  border: 0;
  border-radius: var(--r-full);
  background: transparent;
  color: var(--fg);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard);
}

.cv-ctx-btn:hover {
  background: var(--bg-hover);
}

.cv-ctx-btn[aria-expanded="true"] {
  background: var(--bg-active);
  color: var(--fg);
}

.cv-ctx-btn.icon-only {
  width: 30px;
  padding: 0;
  justify-content: center;
}

.cv-ctx-btn.is-danger {
  color: var(--danger);
}

.cv-ctx-sep {
  width: 1px;
  height: 16px;
  background: var(--line-hairline);
  margin: 0 2px;
  flex-shrink: 0;
}

.cv-branch-menu,
.cv-ctx-menu,
.cv-ctx-more-menu {
  position: fixed;
  z-index: 66;
  min-width: 192px;
  max-width: calc(100vw - 24px);
  max-height: min(60vh, 360px);
  overflow-y: auto;
  border: 1px solid var(--line-hairline);
}

.cv-branch-menu[hidden],
.cv-ctx-menu[hidden],
.cv-ctx-more-menu[hidden] {
  display: none;
}

.cv-branch-menu:not([hidden]),
.cv-ctx-menu:not([hidden]),
.cv-ctx-more-menu:not([hidden]) {
  opacity: 1;
  visibility: visible;
  transform: none;
}

/* ---------- 5. Bottom Bars & AI Copilot Drawer ---------- */
.cv-bottom-left {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 35;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  background: var(--bg-glass-strong);
  backdrop-filter: blur(20px);
  border: 1px solid var(--line-hairline);
  border-radius: var(--r-full);
  box-shadow: var(--shadow-pop);
}

.cv-bar-sep {
  width: 1px;
  height: 14px;
  background: var(--line-hairline);
  margin: 0 3px;
}

.cv-zoom-val {
  height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--fg);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.cv-zoom-val:hover {
  background: var(--bg-hover);
}

.cv-ai-fab {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 36;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  border-radius: var(--r-full);
  background: var(--bg-elevated);
  border: 1px solid var(--line-hairline);
  color: var(--fg);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  box-shadow: var(--shadow-pop);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-standard), transform var(--dur-fast) var(--ease-out);
}

.cv-ai-fab:hover {
  border-color: var(--accent-line);
  transform: translateY(-1px);
}

.cv-ai-fab[hidden] {
  display: none;
}

.cv-ai-drawer {
  position: fixed;
  top: 66px;
  right: 14px;
  bottom: 14px;
  width: 420px;
  z-index: 39;
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--line-hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  overflow: visible;
}

.cv-ai-drawer:has(.pop.is-open) {
  z-index: 45;
}

.cv-ai-drawer[hidden] {
  display: none;
}

.cv-ai-resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 6px;
  cursor: ew-resize;
  z-index: 3;
}

.cv-ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-hairline);
  background: var(--bg-elevated);
  border-radius: calc(var(--r-lg) - 1px) calc(var(--r-lg) - 1px) 0 0;
}

.cv-ai-head-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  color: var(--fg);
}

.cv-ai-head-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cv-ai-context-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--line-hairline);
  font-size: var(--fs-xs);
  color: var(--fg-2);
}

.cv-ai-scroll {
  flex: 1;
  min-height: 0;
  padding: 0;
  background: var(--bg-canvas);
}

[data-theme="dark"] .cv-ai-scroll {
  background: var(--bg-canvas);
}

.cv-ai-empty {
  display: grid;
  gap: 10px;
  padding: 28px 18px 18px;
  text-align: center;
}

.cv-ai-empty h3 {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  color: var(--fg);
}

.cv-ai-empty > p {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--fg-2);
  line-height: var(--lh-normal);
}

.cv-ai-starters {
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
}

.cv-ai-drawer .starter {
  padding: 14px;
  border-radius: var(--r-md);
}

.cv-ai-drawer .cv-ai-thread {
  max-width: none;
  padding: 16px 16px 28px;
  gap: 20px;
}

.cv-ai-drawer .turn-user {
  max-width: 88%;
}

.cv-ai-drawer .turn-user-bubble {
  padding: 9px 13px;
  font-size: var(--fs-sm);
  border-radius: 16px 16px 4px 16px;
}

.cv-ai-drawer .prose {
  font-size: var(--fs-sm);
  line-height: 1.65;
}

.cv-ai-drawer .prose h2 {
  font-size: var(--fs-md);
}

.cv-ai-drawer .prose h3,
.cv-ai-drawer .prose h4 {
  font-size: var(--fs-sm);
}

.cv-ai-drawer .prose table {
  font-size: var(--fs-xs);
}

.cv-ai-drawer .prose th,
.cv-ai-drawer .prose td {
  padding: 6px 9px;
}

.cv-ai-drawer .turn-trace summary {
  font-size: var(--fs-xs);
}

.cv-ai-drawer .turn-ai-foot {
  opacity: 0.72;
}

.cv-ai-drawer .ag-gallery[data-count="2"],
.cv-ai-drawer .ag-gallery[data-count="3"],
.cv-ai-drawer .ag-gallery[data-count="4"],
.cv-ai-drawer .ag-gallery[data-count="many"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.cv-ai-dock {
  position: relative;
  padding: 10px 12px 10px;
  border-top: 1px solid var(--line-hairline);
  background: var(--bg-elevated);
  border-radius: 0 0 calc(var(--r-lg) - 1px) calc(var(--r-lg) - 1px);
}

.cv-ai-scroll-bottom {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  z-index: 4;
}

.cv-ai-dock .composer {
  box-shadow: none;
  border-radius: var(--r-md);
}

.cv-ai-dock .composer-refs {
  padding: 10px 12px 0;
}

.cv-ai-dock .composer-input {
  padding: 12px 14px 4px;
}

.cv-ai-dock .composer .textarea {
  min-height: 36px;
  max-height: 120px;
  font-size: var(--fs-sm);
}

.cv-ai-dock .composer-bar {
  position: relative;
  padding: 6px 10px 10px;
}

.cv-ai-dock #cvAiModelSlot,
.cv-ai-dock #cvAiModelPicker {
  position: static;
}

.cv-ai-dock #cvAiModelPicker > .mp-panel {
  left: auto;
  right: 0;
  width: min(384px, calc(100vw - 32px));
  max-width: calc(100vw - 24px);
}

.cv-ai-dock #cvAiModelPicker > .mp-panel[data-side="top"] {
  top: auto;
  bottom: calc(100% + 6px);
}

.cv-ai-dock .composer-add {
  margin-right: 4px;
}

.cv-ai-quote-sel-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--fg-2);
}

.cv-ai-dock .dock-note {
  margin-top: 7px;
  font-size: var(--fs-2xs);
}

/* ---------- 6. Mobile Responsive (390x844) & Reduced Motion ---------- */
@media (min-width: 768px) and (max-width: 1023px) {
  .cv-head-left {
    z-index: 41;
    max-width: calc(100vw - 28px);
  }

  .cv-head-right {
    top: 64px;
  }

  .cv-side-drawer,
  .cv-ai-drawer {
    top: 112px;
  }
}

@media (max-width: 767px) {
  .cv-hub-container {
    padding-top: 16px;
  }

  .cv-hub-controls {
    width: 100%;
    flex-wrap: wrap;
  }

  .cv-search-box {
    flex: 1 1 100%;
  }

  .cv-sort-select {
    flex: 1 1 auto;
  }

  .cv-head-left {
    top: 8px;
    left: 8px;
    right: 8px;
    max-width: none;
    justify-content: space-between;
  }

  .cv-save-status,
  .cv-brand-mark {
    display: none;
  }

  .cv-head-right {
    top: 56px;
    right: 8px;
    left: 8px;
    justify-content: space-between;
  }

  .cv-tool-rail {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: 8px;
    transform: none;
    flex-direction: row;
    justify-content: space-around;
    overflow-x: auto;
    border-radius: var(--r-full);
  }

  .cv-rail-sep {
    width: 1px;
    height: 20px;
    margin: 0 2px;
  }

  .cv-bottom-left {
    left: 8px;
    bottom: 64px;
  }

  .cv-ai-fab {
    right: 8px;
    bottom: 64px;
  }

  .cv-side-drawer,
  .cv-ai-drawer {
    top: 56px;
    left: 8px;
    right: 8px;
    bottom: 64px;
    width: auto !important;
    z-index: 45;
  }

  .cv-ai-dock #cvAiModelPicker > .mp-panel {
    left: 0;
    right: 0;
    width: 100%;
  }

  .cv-gen-composer {
    left: 8px !important;
    right: 8px !important;
    bottom: 64px !important;
    top: auto !important;
    width: auto;
  }

  .cv-tpl-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cv-card,
  .cv-node,
  .cv-branch-plus,
  .cv-progress-fill,
  .cv-task-bar-fill,
  .cv-ai-fab,
  .cv-ctx-btn,
  .cv-branch-menu,
  .cv-ctx-menu,
  .cv-ctx-more-menu,
  .cv-gc-audio-tab,
  .cv-gc-ref-chip,
  .cv-gc-slot-chip {
    transition: none !important;
  }
  .cv-spinner {
    animation: none !important;
  }
}

/* Canvas Seed Audio Composer Controls */
.cv-gc-audio-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line-hairline);
}

.cv-gc-audio-tab {
  height: 28px;
  padding: 0 11px;
  border-radius: var(--r-full);
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard);
}

.cv-gc-audio-tab:hover {
  background: var(--bg-hover);
  color: var(--fg);
}

.cv-gc-audio-tab[aria-pressed="true"] {
  background: var(--bg-active);
  border-color: var(--line-hairline);
  color: var(--fg);
  font-weight: var(--fw-semibold);
}

.cv-gc-ref-chip,
.cv-gc-slot-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  max-width: 240px;
  padding: 0 8px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-hairline);
  background: var(--bg-subtle);
  color: var(--fg);
  font-size: var(--fs-xs);
  transition: background var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard);
}

.cv-gc-slot-chip {
  cursor: pointer;
  color: var(--fg-2);
}

.cv-gc-slot-chip:hover,
.cv-gc-ref-chip:hover {
  border-color: var(--line-strong);
  background: var(--bg-hover);
  color: var(--fg);
}

.cv-gc-ref-chip.is-linked {
  border-color: var(--accent-line);
}

.cv-gc-ref-chip-main {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.cv-gc-ref-chip-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cv-gc-ref-chip-x {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--fg-3);
  cursor: pointer;
  flex-shrink: 0;
}

.cv-gc-ref-chip-x:hover {
  background: var(--bg-active);
  color: var(--fg);
}

.pop.cv-gc-at-menu {
  position: fixed;
  z-index: 68;
  padding: 6px;
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  border: 1px solid var(--line-hairline);
  box-shadow: var(--shadow-pop);
}

.pop.cv-gc-at-menu .pop-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 240px;
  overflow-y: auto;
}

.pop.cv-gc-at-menu .menu-item.is-active {
  background: var(--bg-active);
  color: var(--fg);
}

.page-canvas-studio .float-dock {
  display: none;
}
