/* ============================================================================
   Playground Landing — Design System & Layout
   ============================================================================ */

/* — Google Font — */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* — Tokens — */
:root {
  --stone-50: #fafaf9;
  --stone-100: #f5f5f4;
  --stone-200: #e7e5e4;
  --stone-300: #d6d3d1;
  --stone-400: #a8a29e;
  --stone-500: #78716c;
  --stone-600: #57534e;
  --stone-700: #44403c;
  --stone-800: #292524;
  --stone-900: #1c1917;

  --amber-400: #fbbf24;
  --amber-500: #f59e0b;
  --blue-500: #3b82f6;
  --green-500: #22c55e;
  --red-500: #ef4444;

  --bg: var(--stone-100);
  --surface: #ffffff;
  --border: var(--stone-200);
  --text: var(--stone-800);
  --text-muted: var(--stone-500);
  --text-faint: var(--stone-400);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --font-handwriting: 'Caveat', cursive;
  --transition: 180ms ease;
}

/* — Reset — */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ============================================================================
   Shell Layout
   ============================================================================ */

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

/* ============================================================================
   Title — top left
   ============================================================================ */

.pg-title {
  position: fixed;
  top: 16px;
  left: 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--stone-900);
  letter-spacing: -0.01em;
  user-select: none;
  z-index: 100;
}

/* ============================================================================
   Vertical Toolbar — top left, below title
   ============================================================================ */

.pg-toolbar-vertical {
  position: fixed;
  top: 52px;
  left: 14px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.pg-toolbar-vertical__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--stone-700);
  cursor: pointer;
  transition: all var(--transition);
}

.pg-toolbar-vertical__btn:hover {
  background: var(--stone-100);
  color: var(--stone-900);
}

.pg-toolbar-vertical__btn.is-active {
  background: var(--stone-100);
  color: var(--stone-900);
}

.pg-toolbar-vertical__btn svg {
  width: 16px;
  height: 14px;
}

/* Comment cursor button */
.pg-toolbar-vertical__btn--comment {
  background: transparent;
  color: var(--stone-700);
  padding: 0;
}

.pg-toolbar-vertical__btn--comment:hover {
  background: transparent;
  color: var(--stone-900);
}

.pg-toolbar-vertical__btn--comment:hover .pg-toolbar-vertical__comment-cursor {
  transform: scale(1.05);
}

.pg-toolbar-vertical__btn--comment.is-active {
  background: transparent;
  box-shadow: none;
}

.pg-toolbar-vertical__btn--comment.is-active .pg-toolbar-vertical__comment-cursor {
  transform: scale(0.95);
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.1),
    inset 0 -4px 6px 0 rgba(0, 0, 0, 0.4),
    inset 0 4px 4px 0 rgba(255, 255, 255, 0.1);
}

.pg-toolbar-vertical__comment-cursor {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50% 50% 50% 5px;
  background: #000000;
  color: #ffffff;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.1),
    inset 0 -4px 6px 0 rgba(0, 0, 0, 0.08),
    inset 0 4px 4px 0 rgba(255, 255, 255, 0.25);
  transition: all 0.2s ease;
  margin: auto;
}

.pg-toolbar-vertical__comment-cursor svg {
  width: 12px;
  height: 12px;
  stroke: white;
}

/* ============================================================================
   Reset Button — inline with /playground title, top left
   ============================================================================ */

.pg-reset-btn {
  position: fixed;
  top: 12px;
  left: 108px;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--stone-400);
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
  box-shadow: none;
  padding: 0;
}

.pg-reset-btn:hover {
  color: var(--stone-700);
  background: var(--stone-200);
}

.pg-reset-btn svg {
  width: 14px;
  height: 14px;
}

/* (Canvas annotations removed — now using static annotations) */

/* ============================================================================
   Canvas
   ============================================================================ */

.pg-canvas-wrapper {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: default;
}

.pg-canvas-wrapper.is-space-down {
  cursor: grab;
}

.pg-canvas-wrapper.is-space-down:active {
  cursor: grabbing;
}

.pg-canvas-wrapper.is-dropping {
  cursor: copy;
}

/* Dot grid background */
.pg-canvas-wrapper::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(0, 0, 0, 0.07) 1px, transparent 1px);
  background-size: 20px 20px;
  z-index: 0;
  pointer-events: none;
}

.pg-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  transform-origin: 0 0;
}

/* Canvas cursor hidden in chat mode */
.pg-canvas-wrapper.is-chat-mode {
  cursor: none;
}

/* ============================================================================
   Canvas Text Components (landing page text items)
   ============================================================================ */

.pg-canvas-text {
  position: absolute;
  min-width: 60px;
  min-height: 24px;
  padding: 8px 12px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--stone-800);
  background: transparent;
  border: 1.5px solid transparent;
  border-radius: 4px;
  outline: none;
  cursor: move;
  white-space: pre-wrap;
  word-break: break-word;
  z-index: 4;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
  resize: none;
  overflow: visible;
}

/* Hover state — subtle outline */
.pg-canvas-text:hover {
  border-color: rgba(59, 130, 246, 0.35);
}

/* Focus / editing state */
.pg-canvas-text:focus {
  border-color: var(--blue-500);
  background: rgba(59, 130, 246, 0.03);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
  cursor: text;
}

/* Selected state (click, not editing) — single blue outline, corner handles added via JS */
.pg-canvas-text.is-selected {
  border-color: var(--blue-500);
  background: rgba(59, 130, 246, 0.02);
}

.pg-canvas-text.is-multi-selected {
  border-color: var(--blue-500);
  background: rgba(59, 130, 246, 0.02);
}

/* Corner handles injected by JS when text node is selected */
.pg-text-handle {
  position: absolute;
  width: 7px;
  height: 7px;
  background: #fff;
  border: 1.5px solid var(--blue-500);
  border-radius: 1px;
  pointer-events: none;
  z-index: 10;
}
.pg-text-handle--tl { top: -4px; left: -4px; }
.pg-text-handle--tr { top: -4px; right: -4px; }
.pg-text-handle--bl { bottom: -4px; left: -4px; }
.pg-text-handle--br { bottom: -4px; right: -4px; }

/* Heading style for canvas text */
.pg-canvas-text--heading {
  font-size: 44px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--stone-900);
  min-width: 560px;
  max-width: 700px;
  text-align: center;
}

/* Description style */
.pg-canvas-text--desc {
  font-size: 16px;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.6;
  min-width: 420px;
  max-width: 500px;
  text-align: center;
}

/* ============================================================================
   Vertical Divider Line (canvas element)
   ============================================================================ */

.pg-canvas-vline {
  position: absolute;
  width: 1px;
  background: var(--stone-300);
  z-index: 3;
  cursor: move;
  transition: background 150ms ease;
}

.pg-canvas-vline:hover {
  background: var(--blue-500);
}

.pg-canvas-vline.is-selected {
  background: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* ============================================================================
   Static Annotations — handwriting arrows (fixed position, hide on canvas move)
   ============================================================================ */

.pg-static-annotation {
  position: fixed;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  pointer-events: none;
  user-select: none;
  z-index: 90;
  gap: 2px;
  transition: opacity 300ms ease;
}

.pg-static-annotation.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.pg-static-annotation__text {
  font-family: var(--font-handwriting);
  font-size: 22px;
  font-weight: 500;
  color: #e05a47;
  line-height: 1;
  white-space: nowrap;
}

.pg-static-annotation__arrow {
  width: 40px;
  height: 40px;
}

/* ============================================================================
   Demo GIF — canvas element, top-right, looks like an image component
   ============================================================================ */

.pg-canvas-demo-gif {
  position: absolute;
  z-index: 4;
  cursor: move;
  user-select: none;
}

.pg-canvas-demo-gif img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-lg);
  display: block;
  pointer-events: none;
}

/* ============================================================================
   Toolbar Divider
   ============================================================================ */

.pg-toolbar-vertical__divider {
  width: 20px;
  height: 1px;
  background: var(--stone-200);
  margin: 3px 0;
}

/* ============================================================================
   Waitlist Label (above CTA when expanded)
   ============================================================================ */

.pg-bottom-bar__waitlist-label {
  font-size: 14px;
  color: var(--text-muted);
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 200ms ease, max-height 200ms ease;
  pointer-events: none;
}

.pg-bottom-bar__waitlist-label.is-visible {
  opacity: 1;
  max-height: 30px;
}

/* ============================================================================
   Components Panel (slides from left, next to toolbar)
   ============================================================================ */

.pg-components-panel {
  position: fixed;
  top: 52px;
  left: 60px;
  bottom: 80px;
  width: 208px;
  z-index: 99;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  opacity: 0;
  transform: translateX(-8px);
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
}

.pg-components-panel.is-open {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.pg-components-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  user-select: none;
}

.pg-components-panel__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: all var(--transition);
}

.pg-components-panel__close:hover {
  color: var(--stone-700);
  background: var(--stone-100);
}

.pg-components-panel__close svg {
  width: 14px;
  height: 14px;
}

.pg-components-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: 0 6px 6px;
}

.pg-components-panel__body::-webkit-scrollbar {
  width: 4px;
}

.pg-components-panel__body::-webkit-scrollbar-track {
  background: transparent;
}

.pg-components-panel__body::-webkit-scrollbar-thumb {
  background: var(--stone-300);
  border-radius: 4px;
}

/* ─── Components Panel: Project Items ─── */

.pg-project-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  font-size: 13px;
  color: var(--stone-700);
  border-radius: 6px;
  cursor: grab;
  transition: background 180ms ease, color 180ms ease;
  user-select: none;
}

.pg-project-item.is-hovered {
  background: var(--stone-100);
  color: var(--stone-900);
}

.pg-project-item__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

/* ============================================================================
   Bottom Static Bar
   ============================================================================ */

.pg-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 24px 20px;
  pointer-events: none;
}

.pg-bottom-bar > * {
  pointer-events: auto;
}

/* Gradient overlay — bottom to top, transparent */
.pg-bottom-bar__gradient {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 120px;
  background: linear-gradient(to top, var(--bg) 0%, var(--bg) 30%, transparent 100%);
  pointer-events: none;
  z-index: -1;
}

/* Left: Black CTA button */
.pg-bottom-bar__left {
  flex-shrink: 0;
}

.pg-bottom-bar__cta {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 24px;
  background: var(--stone-900);
  color: #ffffff;
  border: none;
  border-radius: 999px;
  font-family: var(--font);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.pg-bottom-bar__cta:hover {
  background: #000000;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

/* badge removed — was [waitlist] */

/* Expanded state: transforms into email input */
.pg-bottom-bar__cta.is-expanded {
  padding: 0 6px 0 20px;
  gap: 6px;
  cursor: default;
  width: 300px;
  transition: width 220ms cubic-bezier(0.4, 0, 0.2, 1), padding 220ms ease;
}

.pg-bottom-bar__cta.is-expanded:hover {
  background: var(--stone-900);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.pg-bottom-bar__cta.is-waitlist-loading {
  opacity: 0.75;
  pointer-events: none;
  cursor: wait;
}

.pg-bottom-bar__cta.is-expanded .pg-bottom-bar__cta-text {
  display: none;
}

.pg-bottom-bar__cta__email-input {
  display: none;
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 400;
  color: #ffffff;
  min-width: 0;
}

.pg-bottom-bar__cta__email-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.pg-bottom-bar__cta.is-expanded .pg-bottom-bar__cta__email-input {
  display: block;
}

.pg-bottom-bar__cta__submit {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: none;
  background: #ffffff;
  color: var(--stone-900);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), transform 100ms ease;
}

.pg-bottom-bar__cta__submit:hover {
  background: var(--stone-100);
  transform: scale(1.04);
}

.pg-bottom-bar__cta__submit svg {
  width: 14px;
  height: 14px;
}

.pg-bottom-bar__cta.is-expanded .pg-bottom-bar__cta__submit {
  display: flex;
}

/* Center: nav links */
.pg-bottom-bar__center {
  display: flex;
  align-items: center;
  gap: 32px;
}

.pg-bottom-bar__link {
  font-size: 16px;
  font-weight: 500;
  color: var(--stone-600);
  text-decoration: none;
  transition: color var(--transition);
}

.pg-bottom-bar__link:hover {
  color: var(--stone-900);
}

/* Right: npx command */
.pg-bottom-bar__right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.pg-bottom-bar__try-label {
  font-size: 14px;
  color: var(--text-muted);
}

.pg-bottom-bar__npx {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--stone-200);
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 14px;
  color: var(--stone-800);
  user-select: all;
}

.pg-bottom-bar__copy-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--stone-500);
  cursor: pointer;
  transition: all var(--transition);
}

.pg-bottom-bar__copy-btn:hover {
  background: var(--stone-300);
  color: var(--stone-800);
}

/* ============================================================================
   Node Card (kept for project iframes on canvas)
   ============================================================================ */

.pg-node {
  position: absolute;
  background: transparent;
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: none;
  display: flex;
  flex-direction: column;
}

.pg-node__preview {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--stone-200);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  transition: box-shadow 200ms ease, border-color 200ms ease;
}

.pg-node:hover .pg-node__preview {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.pg-node.is-selected .pg-node__preview {
  box-shadow: 0 0 0 2px var(--blue-500), 0 4px 16px rgba(0, 0, 0, 0.08);
  border-color: var(--blue-500);
}

.pg-node__title-bar {
  position: absolute;
  bottom: 100%;
  left: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 8px;
  cursor: move;
  width: max-content;
  z-index: 10;
}

.pg-node__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--stone-400);
  letter-spacing: 0.02em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  transition: color var(--transition);
}

.pg-node.is-selected .pg-node__title {
  color: var(--blue-500);
}

.pg-node__actions {
  display: none;
  align-items: center;
  gap: 8px;
}

.pg-node.is-selected .pg-node__actions {
  display: flex;
}

.pg-node__preset-group {
  display: flex;
  align-items: center;
  gap: 0px;
}

.pg-node__preset-btn,
.pg-node__btn--preview {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--stone-400);
  cursor: pointer;
  transition: all var(--transition);
}

.pg-node__preset-btn:hover,
.pg-node__btn--preview:hover {
  color: var(--stone-600);
  background: rgba(0, 0, 0, 0.04);
}

.pg-node__preset-btn.is-active {
  color: var(--blue-500);
  background: rgba(59, 130, 246, 0.1);
}

.pg-node__preset-btn svg,
.pg-node__btn--preview svg {
  width: 14px;
  height: 14px;
}

.pg-node__floating-right {
  position: absolute;
  top: 16px;
  left: calc(100% + 12px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  display: none;
  z-index: 10;
}

.pg-node.is-selected .pg-node__floating-right {
  display: flex;
}

.pg-node__floating-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid transparent;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transition: all var(--transition);
}

.pg-node__floating-btn:hover {
  transform: scale(1.05);
}

.pg-node__floating-btn--bolt {
  background: var(--blue-500);
  color: #fff;
}

.pg-node__floating-btn--bolt:hover {
  background: #2563eb;
}

.pg-node__floating-btn--merge {
  background: var(--surface);
  color: var(--stone-500);
  border-color: var(--stone-200);
}

.pg-node__floating-btn--merge:hover {
  color: var(--stone-800);
}

.pg-node__floating-btn svg {
  width: 18px;
  height: 18px;
}

.pg-node__iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  pointer-events: none;
}

.pg-node.is-selected .pg-node__iframe {
  pointer-events: auto;
}

.pg-canvas-wrapper.is-edit-mode .pg-node__iframe {
  pointer-events: auto;
}

/* Circle outline + curved connector for iterations */
.pg-node__circle-badge {
  position: absolute;
  top: -28px;
  right: -28px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--stone-300);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--stone-400);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  pointer-events: none;
  z-index: 6;
  letter-spacing: 0;
}

.pg-node.is-selected .pg-node__circle-badge {
  border-color: var(--blue-500);
  color: var(--blue-500);
}

/* SVG curved connector from parent to child iteration */
.pg-iteration-curve {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 2;
  overflow: visible;
}

.pg-node__resize {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  opacity: 0;
  transition: opacity var(--transition);
}

.pg-node:hover .pg-node__resize {
  opacity: 1;
}

.pg-node__resize::after {
  content: '';
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--stone-300);
  border-bottom: 2px solid var(--stone-300);
}

/* ============================================================================
   Iteration Ghosts
   ============================================================================ */

.pg-iteration-ghosts {
  position: absolute;
  pointer-events: none;
  z-index: 5;
}

.pg-ghost-node {
  position: absolute;
  border: 1.5px dashed rgba(59, 130, 246, 0.3);
  background: rgba(59, 130, 246, 0.04);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(59, 130, 246, 0.4);
  font-weight: 500;
  font-size: 14px;
}

/* ============================================================================
   Cursor Chat
   ============================================================================ */

:root {
  --model-auto: #57534e;
  --model-claude: #d4736e;
  --model-gpt4o: #4a9e8e;
  --model-gemini: #7c6dd8;
}

.pg-cursor-chat {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  display: none;
}

.pg-cursor-chat.is-active {
  display: block;
}

.pg-cursor-chat__bubble {
  width: 28px;
  height: 28px;
  position: relative;
  perspective: 200px;
  cursor: none;
  flex-shrink: 0;
}

.pg-cursor-chat__bubble-face {
  position: absolute;
  inset: 0;
  width: 28px;
  height: 28px;
  border-radius: 50% 50% 50% 5px;
  backface-visibility: hidden;
  background: #ffffff;
  background-size: cover;
  background-position: center;
  outline: 2px solid rgba(255, 255, 255, 0.9);
  outline-offset: 0px;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.18),
    inset 0 -4px 6px 0 rgba(0, 0, 0, 0.08),
    inset 0 4px 4px 0 rgba(255, 255, 255, 0.25);
}

.pg-cursor-chat__bubble-face--next {
  transform: rotateY(180deg);
}

.pg-cursor-chat__box.is-peek {
  opacity: 0.55;
  pointer-events: none;
  transform: scale(0.97);
  transition: opacity 150ms ease, transform 150ms ease;
}

.pg-cursor-chat__box.is-visible-full {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
  transition: opacity 150ms ease, transform 150ms ease;
}

@keyframes bubble-flip-out {
  0% { transform: rotateY(0deg); }
  100% { transform: rotateY(-180deg); }
}

@keyframes bubble-flip-in {
  0% { transform: rotateY(180deg); }
  100% { transform: rotateY(0deg); }
}

.pg-cursor-chat__bubble.is-switching .pg-cursor-chat__bubble-face--current {
  animation: bubble-flip-out 350ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.pg-cursor-chat__bubble.is-switching .pg-cursor-chat__bubble-face--next {
  animation: bubble-flip-in 350ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.pg-cursor-chat__box.is-hidden {
  display: none;
}

.pg-cursor-chat__box {
  position: absolute;
  top: 22px;
  left: 16px;
  width: 300px;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--stone-200);
  border-radius: 18px;
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 0 50px -18px rgba(0, 0, 0, 0.15), 0 2px 12px rgba(0, 0, 0, 0.06);
  pointer-events: auto;
  display: none;
}

.pg-cursor-chat__box.is-peek {
  display: flex;
  opacity: 0.75;
  pointer-events: auto;
  transform: none;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: none;
  border: 1.5px dashed var(--stone-300);
  padding: 10px 14px;
  gap: 0;
}

.pg-cursor-chat__box.is-peek .pg-cursor-chat__element,
.pg-cursor-chat__box.is-peek .pg-cursor-chat__footer {
  display: none !important;
}

.pg-cursor-chat__box.is-peek .pg-cursor-chat__input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pg-cursor-chat__box.is-peek .pg-cursor-chat__send-inline {
  display: flex;
}

.pg-cursor-chat__box.is-visible-full {
  display: flex;
  opacity: 1;
  pointer-events: auto;
  transform: none;
  box-shadow: 0 0 50px -18px rgba(0, 0, 0, 0.15), 0 2px 12px rgba(0, 0, 0, 0.06);
  border: 1px solid var(--stone-200);
}

.pg-cursor-chat__element {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 6px;
  background: var(--stone-50);
  border: 1px solid var(--stone-200);
  border-radius: 20px;
  align-self: flex-start;
  font-size: 13px;
  color: var(--blue-500);
  font-weight: 500;
}

.pg-cursor-chat__element.is-visible {
  display: flex;
}

.pg-cursor-chat__element svg {
  width: 16px;
  height: 16px;
  color: var(--blue-500);
  opacity: 0.7;
}

.pg-cursor-chat__element span {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#chat-element-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: none;
  background: transparent;
  color: var(--stone-400);
  cursor: pointer;
  padding: 0;
  margin-left: 2px;
  transition: color var(--transition);
}

#chat-element-clear:hover {
  color: var(--stone-700);
}

#chat-element-clear svg {
  width: 12px;
  height: 12px;
  color: inherit;
  opacity: 1;
}

.pg-cursor-chat__input-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.pg-cursor-chat__send-inline {
  display: none;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: var(--stone-200);
  color: var(--stone-500);
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
}

.pg-cursor-chat__send-inline:hover {
  background: var(--stone-300);
  color: var(--stone-800);
}

.pg-cursor-chat__send-inline svg {
  width: 12px;
  height: 12px;
}

#chat-input {
  width: 100%;
  min-height: 28px;
  max-height: 100px;
  padding: 4px 0;
  font-size: 14px;
  font-family: var(--font);
  line-height: 1.5;
  color: var(--text);
  background: transparent;
  border: none;
  resize: none;
  outline: none;
  caret-color: var(--stone-600);
}

#chat-input::placeholder {
  color: var(--stone-400);
}

.pg-cursor-chat__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pg-cursor-chat__mention {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  font-size: 13px;
  font-family: var(--font);
  font-weight: 500;
  color: var(--stone-500);
  background: var(--stone-100);
  border: none;
  border-radius: 16px;
  cursor: pointer;
  transition: all var(--transition);
}

.pg-cursor-chat__mention:hover {
  background: var(--stone-200);
  color: var(--stone-700);
}

.pg-cursor-chat__send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: var(--stone-200);
  color: var(--stone-500);
  cursor: pointer;
  transition: all var(--transition);
}

.pg-cursor-chat__send:hover {
  background: var(--stone-300);
  color: var(--stone-800);
}

.pg-cursor-chat__send svg {
  width: 16px;
  height: 16px;
}

/* ============================================================================
   Generation Presence Bubbles (header-style, now floating)
   ============================================================================ */

.pg-generation-ghost {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 50% 50% 50% 4px;
  pointer-events: none;
  opacity: 0.7;
  background: #fff;
  background-size: cover;
  background-position: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15), 0 0 0 2px rgba(255, 255, 255, 0.8);
  transition: opacity 300ms ease;
}

.pg-generation-ghost.is-done {
  opacity: 0.35;
}

/* ============================================================================
   Toast
   ============================================================================ */

.pg-toast-container {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.pg-toast {
  padding: 10px 16px;
  background: var(--stone-800);
  color: white;
  font-size: 13px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
  opacity: 0;
  transform: translateY(8px);
  animation: toast-in 250ms ease forwards;
  pointer-events: auto;
}

.pg-toast.is-error {
  background: var(--red-500);
}

.pg-toast.is-success {
  background: var(--green-500);
  color: var(--stone-900);
}

@keyframes toast-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.pg-toast.is-leaving {
  animation: toast-out 200ms ease forwards;
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* ============================================================================
   Drawing Overlay (SVG)
   ============================================================================ */

.pg-draw-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
  overflow: visible;
}

.pg-canvas-wrapper.is-drawing .pg-draw-svg {
  pointer-events: auto;
  cursor: crosshair;
}

/* ============================================================================
   Image Frames
   ============================================================================ */

.pg-canvas-frame {
  position: absolute;
  display: flex;
  flex-direction: column;
  z-index: 4;
  cursor: move;
}

.pg-canvas-frame__image {
  width: 100%;
  height: calc(100% - 28px);
  object-fit: cover;
  border-radius: var(--radius-lg);
  border: 1px solid var(--stone-200);
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  transition: box-shadow 200ms ease, border-color 200ms ease;
  pointer-events: none;
}

.pg-canvas-frame.is-selected .pg-canvas-frame__image,
.pg-canvas-frame.is-multi-selected .pg-canvas-frame__image {
  box-shadow: 0 0 0 2px var(--blue-500), 0 4px 16px rgba(0, 0, 0, 0.08);
  border-color: var(--blue-500);
}

.pg-canvas-frame__label {
  position: absolute;
  bottom: 100%;
  left: 0;
  padding-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--stone-400);
  letter-spacing: 0.02em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  user-select: none;
}

.pg-canvas-frame.is-selected .pg-canvas-frame__label,
.pg-canvas-frame.is-multi-selected .pg-canvas-frame__label {
  color: var(--blue-500);
}

.pg-canvas-frame__resize {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  opacity: 0;
  transition: opacity var(--transition);
}

.pg-canvas-frame:hover .pg-canvas-frame__resize {
  opacity: 1;
}

.pg-canvas-frame__resize::after {
  content: '';
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--stone-300);
  border-bottom: 2px solid var(--stone-300);
}

/* ============================================================================
   Marquee Selection Rectangle
   ============================================================================ */

.pg-selection-rect {
  position: fixed;
  border: 1.5px solid var(--blue-500);
  background: rgba(59, 130, 246, 0.06);
  border-radius: 2px;
  pointer-events: none;
  z-index: 999;
  display: none;
}

.pg-selection-rect.is-active {
  display: block;
}

.pg-node.is-multi-selected .pg-node__preview {
  box-shadow: 0 0 0 2px var(--blue-500), 0 4px 16px rgba(0, 0, 0, 0.08);
  border-color: var(--blue-500);
}

.pg-node.is-multi-selected .pg-node__title {
  color: var(--blue-500);
}

/* ============================================================================
   @Mention Dropdown
   ============================================================================ */

.pg-mention-dropdown {
  position: fixed;
  z-index: 1100;
  display: none;
  flex-direction: column;
  min-width: 220px;
  max-width: 300px;
  max-height: 220px;
  overflow-y: auto;
  background: #1c1917;
  border-radius: 10px;
  padding: 4px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.2);
}

.pg-mention-dropdown.is-visible {
  display: flex;
}

.pg-mention-dropdown__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 500;
  color: #e7e5e4;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: background 150ms ease;
}

.pg-mention-dropdown__item:hover,
.pg-mention-dropdown__item.is-active {
  background: #363433;
  color: #ffffff;
}

.pg-mention-dropdown__item-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.5;
}

.pg-mention-dropdown__item-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pg-mention-dropdown__item-type {
  margin-left: auto;
  font-size: 11px;
  color: #78716c;
  flex-shrink: 0;
}

/* ============================================================================
   Context Menu
   ============================================================================ */

.pg-context-menu {
  position: fixed;
  z-index: 10000;
  width: 200px;
  background: #252423;
  border: 1px solid #3d3b3a;
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.2);
  display: none;
  flex-direction: column;
  gap: 2px;
}

.pg-context-menu.is-active {
  display: flex;
}

.pg-context-menu__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  color: #e7e5e4;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: background 150ms ease, color 150ms ease;
}

.pg-context-menu__item:hover {
  background: #363433;
  color: #ffffff;
}

.pg-context-menu__item svg {
  width: 15px;
  height: 15px;
  color: #a8a29e;
}

.pg-context-menu__item:hover svg {
  color: #ffffff;
}

.pg-context-menu__item--danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.pg-context-menu__item--danger:hover svg {
  color: #f87171;
}

.pg-context-menu__divider {
  height: 1px;
  background: #3d3b3a;
  margin: 4px 0;
}

/* ============================================================================
   Drag Ghost
   ============================================================================ */

.pg-drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  padding: 6px 14px;
  background: var(--blue-500);
  color: white;
  font-size: 12px;
  font-family: var(--font);
  font-weight: 600;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.35);
  opacity: 0.92;
  white-space: nowrap;
}

/* ============================================================================
   Drop indicator on canvas
   ============================================================================ */

.pg-canvas-wrapper.is-dragover::after {
  content: '';
  position: absolute;
  inset: 8px;
  border: 2px dashed rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-lg);
  pointer-events: none;
  z-index: 5;
  opacity: 0.9;
}

/* ============================================================================
   Spinner
   ============================================================================ */

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

/* ============================================================================
   Utility
   ============================================================================ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}