/* ========================================
   TLDRAW LAYOUT - CANVAS-FIRST DESIGN
   Phase 1: Layout Foundation
   ======================================== */

:root {
  /* Colors */
  --tldraw-bg: #fafafa;
  --tldraw-canvas-bg: #ffffff;
  --tldraw-primary: #3b5bdb;
  --tldraw-text: #1e1e1e;
  --tldraw-text-muted: #5a6c7d;
  --tldraw-border: #e9ecef;

  /* Shadows */
  --tldraw-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  --tldraw-shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);

  /* Dimensions */
  --tldraw-toolbar-height: 64px;
  --tldraw-topbar-height: 56px;
  --tldraw-panel-width: 320px;
  --tldraw-statusbar-height: 32px;

  /* Font */
  --tldraw-font: 'League Spartan', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
}

/* Global Font Application */
html, body {
  font-family: 'League Spartan', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
}

/* ========================================
   BASE RESET
   ======================================== */

.tldraw-layout {
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--tldraw-bg);
  font-family: var(--tldraw-font);
  height: 100vh;
}

/* ========================================
   TOP BAR - MINIMAL HEADER
   ======================================== */

.tldraw-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--tldraw-topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: white;
  border-bottom: 1px solid var(--tldraw-border);
  z-index: 1000;
}

.tldraw-topbar__left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tldraw-topbar__menu {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 6px;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tldraw-text);
  transition: background 0.15s;
}

.tldraw-topbar__menu:hover {
  background: var(--tldraw-bg);
}

.tldraw-topbar__logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 16px;
  color: var(--tldraw-text);
  text-decoration: none;
  transition: opacity 0.15s;
}

.tldraw-topbar__logo:hover {
  opacity: 0.8;
  text-decoration: none;
}

.tldraw-topbar__icon {
  font-size: 20px;
  line-height: 1;
}

.tldraw-topbar__right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tldraw-topbar__user {
  color: var(--tldraw-text-muted);
  font-size: 14px;
  font-weight: 400;
}

.tldraw-topbar__link {
  padding: 6px 12px;
  background: transparent;
  color: var(--tldraw-text);
  border: 1px solid var(--tldraw-border);
  border-radius: 6px;
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  transition: all 0.15s;
  cursor: pointer;
  font-family: inherit;
}

.tldraw-topbar__link:hover {
  background: var(--tldraw-bg);
  text-decoration: none;
}

.tldraw-topbar__cta {
  padding: 8px 16px;
  background: var(--tldraw-primary);
  color: white;
  border: none;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  transition: background 0.15s;
  cursor: pointer;
}

.tldraw-topbar__cta:hover {
  background: #3b5bdb;
  text-decoration: none;
}

/* ========================================
   WORKSPACE - FULLSCREEN CONTAINER
   ======================================== */

.tldraw-workspace {
  position: fixed;
  top: var(--tldraw-topbar-height);
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  background: var(--tldraw-bg);
}

/* ========================================
   EDITOR - MAIN CONTAINER
   ======================================== */

.tldraw-editor {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

/* ========================================
   CANVAS - FULL SCREEN DRAWING AREA
   ======================================== */

.tldraw-canvas {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--tldraw-canvas-bg);
  pointer-events: none;
  z-index: 1;
}

/* Workflow-specific canvas positioning */
.workflow-page .tldraw-canvas {
  top: 80px;
}

.tldraw-canvas-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
}

.tldraw-canvas-element {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
  pointer-events: none;  /* Don't block UI elements by default */
}

/* Only capture pointer events when a drawing tool is active */
.tldraw-canvas-element[data-drawing-enabled="true"] {
  pointer-events: all;
}

.tldraw-canvas__overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.tldraw-canvas__overlay > * {
  pointer-events: all;
}

/* Workflow UI elements must sit above canvas */
.workflow-header {
  position: relative;
  z-index: 9999;
  pointer-events: all;
  background: white;
  padding: 1rem;
}

.tldraw-toolbar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  pointer-events: all;
}

.tldraw-richtext-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.tldraw-text-overlay {
  position: absolute;
  pointer-events: none;
  overflow: hidden;
  white-space: normal;
  word-break: break-word;
  color: #111827;
}

.tldraw-grid-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 1;
}

/* ========================================
   SIDEPANELS - HIDDEN BY DEFAULT
   ======================================== */

.tldraw-sidepanel {
  position: fixed;
  top: var(--tldraw-topbar-height);
  bottom: 0;
  width: var(--tldraw-panel-width);
  background: white;
  border: 1px solid var(--tldraw-border);
  box-shadow: var(--tldraw-shadow-lg);
  overflow-y: auto;
  z-index: 950;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tldraw-sidepanel--left {
  left: 0;
  border-left: none;
  transform: translateX(-100%);
}

.tldraw-sidepanel--right {
  right: 0;
  border-right: none;
  transform: translateX(100%);
}

.tldraw-sidepanel[data-hidden] {
  display: none;
}

.tldraw-sidepanel.is-visible {
  transform: translateX(0);
}

.tldraw-sidepanel__header {
  padding: 16px;
  border-bottom: 1px solid var(--tldraw-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: white;
  z-index: 10;
}

.tldraw-sidepanel__header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--tldraw-text);
}

.tldraw-sidepanel__close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  font-size: 24px;
  cursor: pointer;
  border-radius: 6px;
  color: var(--tldraw-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.15s;
}

.tldraw-sidepanel__close:hover {
  background: var(--tldraw-bg);
}

.tldraw-sidepanel__body {
  padding: 0;
}

.tldraw-sidepanel__panel-section {
  border-bottom: 1px solid var(--tldraw-border);
  padding: 16px;
}

.tldraw-sidepanel__panel-section:last-child {
  border-bottom: none;
}

.tldraw-sidepanel__panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--tldraw-text);
  margin: 0 0 12px 0;
}

/* ========================================
   BOTTOM TOOLBAR - PHASE 2
   ======================================== */

.tldraw-toolbar {
  position: fixed;
  bottom: calc(var(--tldraw-statusbar-height) + 16px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px;
  background: white;
  border: 1px solid var(--tldraw-border);
  border-radius: 8px;
  box-shadow: var(--tldraw-shadow);
  z-index: 900;
}

.tldraw-toolbar__group {
  display: flex;
  gap: 4px;
  padding: 0 4px;
  border-left: 1px solid var(--tldraw-border);
}

.tldraw-toolbar__group:first-child {
  border-left: none;
  padding-left: 0;
}

.tldraw-toolbar__button {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--tldraw-text);
  font-size: 18px;
  transition: all 0.15s;
  position: relative;
}

.tldraw-toolbar__button:hover {
  background: var(--tldraw-bg);
}

.tldraw-toolbar__button.is-active {
  background: var(--tldraw-primary);
  color: white;
}

.tldraw-toolbar__button[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

.tldraw-toolbar__button[disabled]:hover {
  background: transparent;
}

/* Tooltip for toolbar buttons */
.tldraw-toolbar__button[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  background: var(--tldraw-text);
  color: white;
  font-size: 12px;
  white-space: nowrap;
  border-radius: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

.tldraw-toolbar__button:hover[data-tooltip]::after {
  opacity: 1;
}

/* ========================================
   SHAPE PICKER - DROPDOWN PANEL
   ======================================== */

.tldraw-toolbar__shape-picker-wrapper {
  position: relative;
}

.tldraw-toolbar__shape-picker-button {
  display: flex !important;
  align-items: center;
  gap: 4px;
  padding: 0 8px !important;
  min-width: 56px !important;
}

.tldraw-toolbar__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.tldraw-toolbar__dropdown-arrow {
  font-size: 10px;
  opacity: 0.6;
  margin-left: -2px;
}

.tldraw-shape-picker {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: white;
  border: 1px solid var(--tldraw-border);
  border-radius: 8px;
  box-shadow: var(--tldraw-shadow-lg);
  padding: 8px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  z-index: 1000;
}

.tldraw-shape-picker[data-open] {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: all;
}

.tldraw-shape-picker__grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  min-width: 220px;
}

.tldraw-shape-picker__shape {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--tldraw-text);
  font-size: 18px;
  transition: all 0.15s;
  position: relative;
}

.tldraw-shape-picker__shape:hover {
  background: var(--tldraw-bg);
}

.tldraw-shape-picker__shape.is-active {
  background: var(--tldraw-primary);
  color: white;
}

/* Tooltip for shape picker buttons */
.tldraw-shape-picker__shape[title]:hover::after {
  content: attr(title);
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  background: var(--tldraw-text);
  color: white;
  font-size: 11px;
  white-space: nowrap;
  border-radius: 4px;
  z-index: 1001;
  pointer-events: none;
}

/* ========================================
   STATUS BAR - PHASE 2
   ======================================== */

.tldraw-statusbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--tldraw-statusbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: white;
  border-top: 1px solid var(--tldraw-border);
  font-size: 12px;
  color: var(--tldraw-text-muted);
  z-index: 850;
}

.tldraw-statusbar__left,
.tldraw-statusbar__right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tldraw-statusbar__zoom {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tldraw-statusbar__zoom-button {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  color: var(--tldraw-text);
  font-size: 14px;
  transition: background 0.15s;
}

.tldraw-statusbar__zoom-button:hover {
  background: var(--tldraw-bg);
}

.tldraw-statusbar__zoom-value {
  min-width: 48px;
  text-align: center;
  font-weight: 500;
  color: var(--tldraw-text);
}

.tldraw-statusbar__divider {
  width: 1px;
  height: 16px;
  background: var(--tldraw-border);
  margin: 0 8px;
}

.tldraw-statusbar__grid-toggle {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--tldraw-border);
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  color: var(--tldraw-text);
  font-size: 14px;
  transition: all 0.15s;
}

.tldraw-statusbar__grid-toggle:hover {
  background: var(--tldraw-bg);
  border-color: var(--tldraw-text-muted);
}

.tldraw-statusbar__grid-toggle.is-active,
.tldraw-statusbar__grid-toggle[aria-pressed="true"] {
  background: var(--tldraw-primary);
  border-color: var(--tldraw-primary);
  color: white;
}

.tldraw-statusbar__grid-icon {
  font-family: monospace;
  font-weight: bold;
  font-size: 16px;
}

.tldraw-statusbar__brand {
  font-weight: 500;
  color: var(--tldraw-text-muted);
}

/* ========================================
   FLOATING STYLE PANEL - PHASE 3
   ======================================== */

.tldraw-stylepanel {
  position: fixed;
  right: 16px;
  top: calc(var(--tldraw-topbar-height) + 16px);
  width: 280px;
  max-height: calc(100vh - var(--tldraw-topbar-height) - var(--tldraw-statusbar-height) - 32px);
  background: white;
  border: 1px solid var(--tldraw-border);
  border-radius: 8px;
  box-shadow: var(--tldraw-shadow);
  z-index: 920;
  overflow-y: auto;
  opacity: 0;
  transform: translateX(calc(100% + 16px));
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.tldraw-stylepanel.is-visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: all;
}

.tldraw-stylepanel__header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--tldraw-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: white;
  z-index: 10;
}

.tldraw-stylepanel__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--tldraw-text);
  margin: 0;
}

.tldraw-stylepanel__close {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  border-radius: 4px;
  color: var(--tldraw-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.15s;
}

.tldraw-stylepanel__close:hover {
  background: var(--tldraw-bg);
}

.tldraw-stylepanel__body {
  padding: 16px;
}

.tldraw-stylepanel__section {
  margin-bottom: 20px;
}

.tldraw-stylepanel__section:last-child {
  margin-bottom: 0;
}

.tldraw-stylepanel__section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--tldraw-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 12px 0;
}

.tldraw-stylepanel__control {
  margin-bottom: 12px;
}

.tldraw-stylepanel__control:last-child {
  margin-bottom: 0;
}

.tldraw-stylepanel__label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--tldraw-text);
  margin-bottom: 6px;
}

.tldraw-stylepanel__color-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.tldraw-stylepanel__color-button {
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}

.tldraw-stylepanel__color-button:hover {
  transform: scale(1.1);
}

.tldraw-stylepanel__color-button.is-active {
  border-color: var(--tldraw-primary);
  box-shadow: 0 0 0 2px rgba(76, 110, 245, 0.2);
}

.tldraw-stylepanel__slider {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--tldraw-border), var(--tldraw-text));
  appearance: none;
  cursor: pointer;
}

.tldraw-stylepanel__slider::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--tldraw-primary);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.tldraw-stylepanel__slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--tldraw-primary);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.tldraw-stylepanel__value {
  display: inline-block;
  min-width: 32px;
  text-align: right;
  font-size: 13px;
  color: var(--tldraw-text-muted);
  margin-left: 8px;
}

.tldraw-stylepanel__button-group {
  display: flex;
  gap: 6px;
}

.tldraw-stylepanel__style-button {
  flex: 1;
  min-height: 36px;
  padding: 6px 8px;
  background: var(--tldraw-background);
  border: 2px solid var(--tldraw-border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tldraw-text);
}

.tldraw-stylepanel__style-button:hover {
  background: var(--tldraw-hover);
  border-color: var(--tldraw-border-hover);
}

.tldraw-stylepanel__style-button.is-active {
  background: var(--tldraw-primary);
  border-color: var(--tldraw-primary);
  color: white;
}

.tldraw-stylepanel__style-button svg {
  width: 24px;
  height: 24px;
  display: block;
}

.tldraw-stylepanel__button {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--tldraw-border);
  background: transparent;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--tldraw-text);
  cursor: pointer;
  transition: all 0.15s;
}

.tldraw-stylepanel__button:hover {
  background: var(--tldraw-bg);
}

.tldraw-stylepanel__button.is-active {
  background: var(--tldraw-primary);
  border-color: var(--tldraw-primary);
  color: white;
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

.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;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 768px) {
  .tldraw-topbar {
    padding: 0 12px;
  }

  .tldraw-topbar__user {
    display: none;
  }

  .tldraw-sidepanel {
    width: calc(100% - 32px);
    max-width: 320px;
  }

  .tldraw-toolbar {
    padding: 6px;
    gap: 2px;
  }

  .tldraw-toolbar__button {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  .tldraw-toolbar__group {
    gap: 2px;
  }

  .tldraw-statusbar {
    padding: 0 12px;
    font-size: 11px;
  }

  .tldraw-statusbar__left,
  .tldraw-statusbar__right {
    gap: 8px;
  }

  .tldraw-stylepanel {
    right: 8px;
    width: 260px;
  }
}

@media (max-width: 480px) {
  .tldraw-topbar__logo {
    font-size: 14px;
  }

  .tldraw-topbar__icon {
    font-size: 18px;
  }

  .tldraw-sidepanel {
    width: 100%;
    max-width: none;
  }

  .tldraw-toolbar__button {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  .tldraw-statusbar__brand {
    display: none;
  }

  .tldraw-stylepanel {
    right: 0;
    left: 0;
    width: 100%;
    top: auto;
    bottom: calc(var(--tldraw-statusbar-height) + var(--tldraw-toolbar-height) + 32px);
    max-height: 40vh;
    border-radius: 8px 8px 0 0;
  }
}

/* ========================================
   TRANSITIONS & ANIMATIONS
   ======================================== */

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

/* ========================================
   FOCUS STYLES - ACCESSIBILITY
   ======================================== */

.tldraw-topbar__menu:focus-visible,
.tldraw-topbar__link:focus-visible,
.tldraw-topbar__cta:focus-visible,
.tldraw-sidepanel__close:focus-visible,
.tldraw-toolbar__button:focus-visible,
.tldraw-statusbar__zoom-button:focus-visible,
.tldraw-statusbar__grid-toggle:focus-visible,
.tldraw-stylepanel__close:focus-visible,
.tldraw-stylepanel__color-button:focus-visible,
.tldraw-stylepanel__slider:focus-visible,
.tldraw-stylepanel__button:focus-visible {
  outline: 2px solid var(--tldraw-primary);
  outline-offset: 2px;
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
  .tldraw-topbar,
  .tldraw-sidepanel,
  .tldraw-toolbar,
  .tldraw-statusbar,
  .tldraw-stylepanel {
    display: none;
  }

  .tldraw-workspace {
    top: 0;
  }

  .tldraw-canvas {
    position: relative;
  }
}

/* ======================================== */
/* ORIGINAL APPLICATION.CSS BELOW */
/* ======================================== */


:root {
  --color-surface: #f8fafc;
  --color-surface-muted: #eef2ff;
  --color-surface-strong: #ffffff;
  --color-border: #d0d7e2;
  --color-border-strong: #b0bbcc;
  --color-text: #1f2937;
  --color-text-muted: #6b7280;
  --color-accent: #2563eb;
  --color-success: #16a34a;
  --color-danger: #dc2626;
  --radius-panel: 12px;
  --shadow-panel: 0 18px 40px rgba(15, 23, 42, 0.12);
  --font-sans: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: #f5f6f9;
  margin: 0;
}

.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;
}

a,
button,
input,
textarea,
select {
  font-family: inherit;
}

a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover,
a:focus-visible {
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ */
/* Layout                                                              */
/* ------------------------------------------------------------------ */

.main-container {
  max-width: 960px;
  margin: 24px auto 48px;
  padding: 0 24px;
}

.document-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(520px, 1fr) minmax(220px, 280px);
  gap: 20px;
  align-items: flex-start;
  margin-top: 24px;
}

@media (max-width: 1280px) {
  .document-layout {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  }
}

@media (max-width: 840px) {
  .document-layout {
    grid-template-columns: 1fr;
  }
}

.document-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.document-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.toolbar {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--color-surface-strong);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-panel);
}

.toolbar__group {
  display: inline-flex;
  gap: 8px;
}

.toolbar__group + .toolbar__group::before {
  content: '';
  display: inline-block;
  width: 1px;
  height: 24px;
  background: var(--color-border);
  margin-right: 4px;
}


.toolbar__button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-surface);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}

.toolbar__button:hover,
.toolbar__button:focus-visible {
  border-color: var(--color-accent);
  background: rgba(37, 99, 235, 0.08);
}

.toolbar__button.is-active {
  border-color: var(--color-accent);
  background: rgba(37, 99, 235, 0.12);
  color: var(--color-accent);
}

.toolbar__icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
}

.toolbar__button[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  background: #0f172a;
  color: #ffffff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 100ms ease;
  z-index: 6;
}

.toolbar__button:hover::after,
.toolbar__button:focus-visible::after {
  opacity: 1;
}

.document-canvas-wrapper {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.document-canvas-stage {
  position: relative;
  display: inline-flex;
}

.document-toolbar {
  display: inline-flex;
  gap: 10px;
  flex-wrap: wrap;
}

.document-toolbar button {
  position: relative;
  border: 1px solid var(--color-border);
  background: var(--color-surface-strong);
  color: var(--color-text);
  border-radius: 12px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.document-toolbar__group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 12px;
}

.document-toolbar__zoom {
  min-width: 56px;
  text-align: center;
  font-weight: 600;
  font-size: 13px;
  color: var(--color-text);
}

.document-toolbar button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.document-toolbar button:hover:not(:disabled),
.document-toolbar button:focus-visible:not(:disabled) {
  border-color: var(--color-accent);
  background: rgba(37, 99, 235, 0.08);
}

.document-toolbar button::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  background: #0f172a;
  color: #ffffff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 100ms ease;
  z-index: 5;
}

.document-toolbar button:hover::after,
.document-toolbar button:focus-visible::after {
  opacity: 1;
}

.document-canvas {
  width: min(100%, 840px);
  aspect-ratio: 4 / 3;
  border-radius: 16px;
  border: 1px solid var(--color-border);
  background: #ffffff;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.15);
}

.document-canvas--hand {
  cursor: grab;
}

.document-canvas--hand-active {
  cursor: grabbing;
}

.document-canvas--eraser {
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="%23ff4466" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="8" y1="12" x2="16" y2="12"/></svg>') 12 12, crosshair, auto;
}

.document-canvas--text {
  cursor: text;
}

.document-canvas-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.minimap {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 200px;
  height: 140px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.18);
  background: rgba(15, 23, 42, 0.65);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.32);
  overflow: hidden;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 180ms ease;
  z-index: 8;
}

.minimap[hidden] {
  display: none !important;
}

.minimap__canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.minimap__viewport {
  position: absolute;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.5);
  pointer-events: none;
  transition: transform 100ms ease, width 100ms ease, height 100ms ease;
}

.document-canvas-overlay--grid {
  --grid-size: 40px;
  --grid-line-weight: 1px;
  background-image:
    linear-gradient(rgba(37, 99, 235, 0.08) var(--grid-line-weight, 1px), transparent var(--grid-line-weight, 1px)),
    linear-gradient(90deg, rgba(37, 99, 235, 0.08) var(--grid-line-weight, 1px), transparent var(--grid-line-weight, 1px));
  background-size: var(--grid-size, 40px) var(--grid-size, 40px);
  background-position: 0 0;
}

.canvas-snap-guide {
  position: absolute;
  pointer-events: none;
  background: rgba(99, 102, 241, 0.85);
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.24);
  z-index: 6;
}

.canvas-snap-guide--vertical {
  width: 1px;
  top: 0;
  bottom: 0;
}

.canvas-snap-guide--horizontal {
  height: 1px;
  left: 0;
  right: 0;
}

.canvas-snap-guide--intersection {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid rgba(37, 99, 235, 0.9);
  background: #ffffff;
  transform: translate(-50%, -50%);
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.35);
}

.canvas-ghost {
  position: absolute;
  border: 1px dashed var(--color-accent);
  background: rgba(37, 99, 235, 0.12);
  pointer-events: none;
  box-sizing: border-box;
}

.canvas-ghost--ellipse {
  border-radius: 50%;
}

.canvas-ghost--diamond {
  border: none;
  background: transparent;
}

.canvas-ghost--diamond::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(37, 99, 235, 0.12);
  border: 1px dashed var(--color-accent);
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
  box-sizing: border-box;
}

.canvas-ghost--triangle,
.canvas-ghost--polygon,
.canvas-ghost--star,
.canvas-ghost--arrow,
.canvas-ghost--arrow-left,
.canvas-ghost--arrow-up,
.canvas-ghost--arrow-down,
.canvas-ghost--pentagon,
.canvas-ghost--hexagon,
.canvas-ghost--octagon,
.canvas-ghost--rhombus,
.canvas-ghost--rhombus-2,
.canvas-ghost--trapezoid,
.canvas-ghost--oval,
.canvas-ghost--line,
.canvas-ghost--x-box,
.canvas-ghost--check-box,
.canvas-ghost--heart,
.canvas-ghost--cloud {
  border: none;
  background: transparent;
  position: relative;
}

.canvas-ghost--triangle::before,
.canvas-ghost--polygon::before,
.canvas-ghost--star::before,
.canvas-ghost--arrow::before,
.canvas-ghost--arrow-left::before,
.canvas-ghost--arrow-up::before,
.canvas-ghost--arrow-down::before,
.canvas-ghost--pentagon::before,
.canvas-ghost--hexagon::before,
.canvas-ghost--octagon::before,
.canvas-ghost--rhombus::before,
.canvas-ghost--rhombus-2::before,
.canvas-ghost--trapezoid::before,
.canvas-ghost--oval::before,
.canvas-ghost--line::before,
.canvas-ghost--heart::before,
.canvas-ghost--cloud::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(37, 99, 235, 0.12);
  border: 1px dashed var(--color-accent);
  box-sizing: border-box;
}

.canvas-ghost--line::before {
  border: none;
  background: none;
}

.canvas-ghost--line::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 0;
  border-top: 2px dashed var(--color-accent);
  transform-origin: 50% 50%;
  transform: translateY(-50%);
}

.canvas-ghost--triangle::before {
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
}

.canvas-ghost--polygon::before {
  clip-path: polygon(50% 0%, 90% 25%, 90% 75%, 50% 100%, 10% 75%, 10% 25%);
}

.canvas-ghost--star::before {
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

.canvas-ghost--arrow::before {
  clip-path: polygon(0% 40%, 60% 40%, 60% 20%, 100% 50%, 60% 80%, 60% 60%, 0% 60%);
}

.canvas-ghost--arrow-left::before {
  clip-path: polygon(100% 40%, 40% 40%, 40% 20%, 0% 50%, 40% 80%, 40% 60%, 100% 60%);
}

.canvas-ghost--arrow-up::before {
  clip-path: polygon(40% 100%, 40% 40%, 20% 40%, 50% 0%, 80% 40%, 60% 40%, 60% 100%);
}

.canvas-ghost--arrow-down::before {
  clip-path: polygon(40% 0%, 40% 60%, 20% 60%, 50% 100%, 80% 60%, 60% 60%, 60% 0%);
}

.canvas-ghost--pentagon::before {
  clip-path: polygon(50% 0%, 100% 38%, 80% 100%, 20% 100%, 0% 38%);
}

.canvas-ghost--hexagon::before {
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
}

.canvas-ghost--octagon::before {
  clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
}

.canvas-ghost--rhombus::before {
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

.canvas-ghost--rhombus-2::before {
  clip-path: polygon(20% 0%, 100% 20%, 80% 100%, 0% 80%);
}

.canvas-ghost--trapezoid::before {
  clip-path: polygon(20% 0%, 80% 0%, 100% 100%, 0% 100%);
}

.canvas-ghost--oval::before {
  border-radius: 50%;
  clip-path: ellipse(50% 35% at 50% 50%);
}

.canvas-ghost--heart::before {
  clip-path: path('M50% 85% L12% 45% C0% 30% 5% 10% 23% 10% C35% 10% 42% 18% 50% 28% C58% 18% 65% 10% 77% 10% C95% 10% 100% 30% 88% 45% Z');
}

.canvas-ghost--cloud::before {
  clip-path: path('M20% 70% C8% 70% 6% 50% 18% 44% C18% 30% 34% 18% 48% 25% C55% 12% 75% 12% 82% 27% C94% 32% 94% 54% 82% 60% C78% 78% 58% 85% 42% 80% C35% 88% 20% 86% 20% 70%');
}

.canvas-ghost--x-box,
.canvas-ghost--check-box {
  border: 2px dashed var(--color-accent);
  background: rgba(37, 99, 235, 0.08);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.15);
}

.canvas-ghost--x-box::before,
.canvas-ghost--check-box::before {
  display: none;
}

.canvas-ghost--x-box::after,
.canvas-ghost--check-box::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.canvas-ghost--x-box::after {
  background:
    linear-gradient(
      45deg,
      transparent 0,
      transparent calc(50% - 1px),
      var(--color-accent) calc(50% - 1px),
      var(--color-accent) calc(50% + 1px),
      transparent calc(50% + 1px)
    ),
    linear-gradient(
      -45deg,
      transparent 0,
      transparent calc(50% - 1px),
      var(--color-accent) calc(50% - 1px),
      var(--color-accent) calc(50% + 1px),
      transparent calc(50% + 1px)
    );
}

.canvas-ghost--check-box::after {
  background:
    linear-gradient(
      135deg,
      transparent 0,
      transparent 45%,
      rgba(59, 130, 246, 0.7) 45%,
      rgba(59, 130, 246, 0.7) 55%,
      transparent 55%
    ),
    linear-gradient(
      -45deg,
      transparent 0,
      transparent 30%,
      rgba(59, 130, 246, 0.7) 30%,
      rgba(59, 130, 246, 0.7) 40%,
      transparent 40%
    );
  background-position: center;
  background-size: 60% 60%;
  background-repeat: no-repeat;
}

.canvas-ghost--sticky-note {
  border-radius: 10px;
  background: rgba(253, 230, 138, 0.35);
  border: 1px dashed rgba(245, 158, 11, 0.8);
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.25);
}

.canvas-ghost--note {
  border-radius: 12px;
  background: rgba(219, 234, 254, 0.4);
  border: 1px dashed rgba(59, 130, 246, 0.75);
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.18);
}

.canvas-ghost--frame {
  border: 2px dashed var(--color-accent);
  background: rgba(37, 99, 235, 0.08);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.15);
}

.canvas-lasso {
  position: absolute;
  border: 1px dashed rgba(59, 130, 246, 0.85);
  border-radius: 12px;
  background: rgba(59, 130, 246, 0.12);
  pointer-events: none;
  box-sizing: border-box;
  z-index: 7;
}

.selection-box {
  position: absolute;
  pointer-events: none;
  border-radius: 6px;
  transform-origin: center center;
  transform: translate(-50%, -50%);
  box-sizing: border-box;
  z-index: 11;
  overflow: visible;
}

.selection-box__outline {
  position: absolute;
  inset: 0;
  border: 1.5px dashed rgba(59, 130, 246, 0.85);
  border-radius: inherit;
  background: rgba(59, 130, 246, 0.12);
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.18);
  pointer-events: none;
}

.selection-box__handle {
  pointer-events: auto;
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  background: #ff3b30;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  --handle-translate-x: 0;
  --handle-translate-y: 0;
  transform: translate(var(--handle-translate-x), var(--handle-translate-y));
  animation: none;
}

.selection-box__handle::before {
  content: '';
  width: 0;
  height: 0;
  display: none;
}

.selection-box__handle:active {
  cursor: grabbing;
  transform: translate(var(--handle-translate-x), var(--handle-translate-y)) scale(0.92);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.26);
}

.video-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  pointer-events: none;
  z-index: 7;
}

.video-overlay__button {
  pointer-events: auto;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  border: none;
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.35);
}

.video-overlay__button:disabled {
  opacity: 0.5;
  cursor: default;
}

.video-overlay__icon {
  font-size: 20px;
  line-height: 1;
}

.video-overlay__label {
  pointer-events: none;
  background: rgba(15, 23, 42, 0.85);
  color: #f8fafc;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.28);
}

.selection-box__handle--resize {
  top: auto;
  left: auto;
  cursor: nwse-resize;
  --handle-translate-x: 50%;
  --handle-translate-y: 50%;
}

.selection-box__handle--resize-nw {
  top: 0;
  left: 0;
  cursor: nw-resize;
  --handle-translate-x: -50%;
  --handle-translate-y: -50%;
}

.selection-box__handle--resize-ne {
  top: 0;
  right: 0;
  cursor: ne-resize;
  --handle-translate-x: 50%;
  --handle-translate-y: -50%;
}

.selection-box__handle--resize-se {
  bottom: 0;
  right: 0;
  cursor: se-resize;
  --handle-translate-x: 50%;
  --handle-translate-y: 50%;
}

.selection-box__handle--resize-sw {
  bottom: 0;
  left: 0;
  cursor: sw-resize;
  --handle-translate-x: -50%;
  --handle-translate-y: 50%;
}

.selection-box__handle--rotate {
  top: -32px;
  left: 50%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #2563eb;
  border: 2px solid #ffffff;
  cursor: grab;
  --handle-translate-x: -50%;
  --handle-translate-y: -50%;
  animation: none;
}

.selection-box__pivot {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  background: #ff3b30;
  box-shadow: 0 6px 12px rgba(15, 23, 42, 0.28);
  pointer-events: none;
}

.selection-box__pivot::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 999px;
  background: #ffe0dd;
}

@keyframes selection-handle-pulse {
  0%, 100% {
    opacity: 1;
    transform: translate(var(--handle-translate-x), var(--handle-translate-y)) scale(1);
  }
  50% {
    opacity: 0.55;
    transform: translate(var(--handle-translate-x), var(--handle-translate-y)) scale(1.2);
  }
}

.selection-box__handle--rotate:active {
  cursor: grabbing;
}

/* Corner rotation zones (tldraw-style) - INVISIBLE hit areas outside corners */
/* Only the cursor changes when hovering - no visible icons */
.selection-box__rotate-corner {
  position: absolute;
  width: 24px !important;
  height: 24px !important;
  min-width: 24px;
  min-height: 24px;
  pointer-events: auto;
  background: transparent !important;
  border: none;
  z-index: 10;
  box-sizing: border-box;
}

/* Position corners outside the selection box */
.selection-box__rotate-corner--nw {
  top: 0;
  left: 0;
  transform: translate(-100%, -100%);
}

.selection-box__rotate-corner--ne {
  top: 0;
  right: 0;
  transform: translate(100%, -100%);
}

.selection-box__rotate-corner--se {
  bottom: 0;
  right: 0;
  transform: translate(100%, 100%);
}

.selection-box__rotate-corner--sw {
  bottom: 0;
  left: 0;
  transform: translate(-100%, 100%);
}

/* No hover background - keep completely invisible */
.selection-box__rotate-corner:hover {
  background: transparent !important;
}

/* No ::after pseudo-elements - completely invisible */

.selection-box__rotate-corner:active {
  cursor: grabbing;
}

.file-drop-indicator {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(59, 130, 246, 0.1);
  backdrop-filter: blur(2px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.file-drop-indicator__content {
  background: rgba(255, 255, 255, 0.95);
  border: 2px dashed rgba(59, 130, 246, 0.8);
  border-radius: 12px;
  padding: 3rem;
  text-align: center;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.file-drop-indicator__icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.file-drop-indicator__text {
  font-size: 1.25rem;
  font-weight: 600;
  color: rgba(30, 58, 138, 0.9);
}

.text-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transform-origin: top left;
  z-index: 6;
}

.text-overlay__content {
  min-height: 100%;
  width: 100%;
  color: #111827;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  hyphens: auto;
  user-select: none;
  outline: none;
  padding: 4px 6px;
  margin: 0;
}

.text-overlay--editing {
  pointer-events: auto;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.5);
  background: rgba(255, 255, 255, 0.95);
  border-radius: 4px;
}

.text-overlay--editing .text-overlay__content {
  user-select: text;
  cursor: text;
  min-height: 100%;
}

.asset-preview {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.asset-preview__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
}

.asset-preview__dialog {
  position: relative;
  background: #ffffff;
  border-radius: 16px;
  padding: 24px;
  width: min(90vw, 960px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.35);
  pointer-events: auto;
}

.asset-preview__close {
  position: absolute;
  top: 12px;
  right: 12px;
  border: none;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: #475569;
}

.asset-preview__header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.asset-preview__header h2 {
  font-size: 20px;
  margin: 0;
}

.asset-preview__meta {
  font-size: 13px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.asset-preview__body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.asset-preview__video {
  width: 100%;
  max-height: 70vh;
  border-radius: 12px;
  background: #000;
}

.laser-trail {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  transform: translate(-50%, -50%) scale(0.7);
  background: var(--laser-color, rgba(239, 68, 68, 0.9));
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.35);
  pointer-events: none;
  animation: laser-trail-fade 0.6s ease-out forwards;
  z-index: 12;
}

.note-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 15;
}

.note-marker {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(30, 64, 175, 0.95);
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transform: translate(-50%, -110%);
  box-shadow: 0 6px 18px rgba(30, 64, 175, 0.35);
  pointer-events: auto;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.note-marker:hover,
.note-marker:focus-visible {
  transform: translate(-50%, -120%);
  box-shadow: 0 8px 22px rgba(30, 64, 175, 0.45);
}

.note-marker__icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  font-size: 10px;
  line-height: 1;
}

.note-marker__count {
  font-variant-numeric: tabular-nums;
}

@keyframes laser-trail-fade {
  0% {
    opacity: 0.9;
    transform: translate(-50%, -50%) scale(0.7);
  }
  60% {
    opacity: 0.45;
    transform: translate(-50%, -50%) scale(1.15);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.6);
  }
}

.document-cheatsheet {
  background: var(--color-surface-strong);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.document-cheatsheet summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--color-text);
}

.document-cheatsheet[open] {
  box-shadow: 0 18px 32px rgba(15, 23, 42, 0.08);
}

/* ------------------------------------------------------------------ */
/* Panel foundation                                                    */
/* ------------------------------------------------------------------ */

.panel,
.layer-panel,
.asset-panel,
.document-collaborators {
  background: var(--color-surface-strong);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-panel);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 240px;
}

.panel__header,
.layer-panel__header,
.asset-panel__header,
.document-collaborators__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.panel__title,
.layer-panel__title,
.asset-panel__title,
.document-collaborators__title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--color-text);
}

.panel__meta,
.layer-panel__meta,
.asset-panel__meta,
.document-collaborators__hint {
  font-size: 12px;
  color: var(--color-text-muted);
  margin: 0;
}

.panel__actions,
.layer-panel__actions,
.asset-panel__actions {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.panel__button,
.layer-panel__action,
.asset-panel__action,
.asset-panel__upload-label {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.panel__button:hover,
.panel__button:focus-visible,
.layer-panel__action:hover,
.layer-panel__action:focus-visible,
.asset-panel__action:hover,
.asset-panel__action:focus-visible,
.asset-panel__upload-label:hover,
.asset-panel__upload-label:focus-visible {
  border-color: var(--color-accent);
  background: rgba(37, 99, 235, 0.08);
}

/* ------------------------------------------------------------------ */
/* Style inspector                                                     */
/* ------------------------------------------------------------------ */

.style-inspector {
  background: var(--color-surface-strong);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-panel);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 240px;
  transition: opacity 120ms ease;
}

.style-inspector.is-loading {
  opacity: 0.65;
  pointer-events: none;
}

.style-inspector__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.style-inspector__header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.style-inspector__selection {
  font-size: 12px;
  color: var(--color-text-muted);
}

.style-inspector__empty {
  font-size: 13px;
  color: var(--color-text-muted);
  background: var(--color-surface-muted);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

.style-inspector__form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.style-inspector__preview {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface-muted);
}

.style-inspector__preview-shape {
  font-size: 24px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.1);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
}

.style-inspector__preview-shape--connector {
  position: relative;
  width: 100%;
  max-width: 220px;
  height: 36px;
  padding: 0;
  background-image: linear-gradient(var(--connector-color, #2563eb), var(--connector-color, #2563eb));
  background-repeat: no-repeat;
  background-position: center;
  background-size: calc(100% - 36px) var(--connector-width, 2px);
  border: none;
  box-shadow: none;
}

.style-inspector__preview-shape--connector[data-connector-dash="dashed"] {
  background-image: repeating-linear-gradient(
    to right,
    var(--connector-color, #2563eb) 0,
    var(--connector-color, #2563eb) 8px,
    transparent 8px,
    transparent 16px
  );
}

.style-inspector__preview-shape--connector[data-connector-dash="dotted"] {
  background-image: radial-gradient(var(--connector-color, #2563eb) 1px, transparent 1px);
  background-size: 8px var(--connector-width, 2px);
  background-repeat: repeat-x;
}

.style-inspector__preview-shape--connector::before,
.style-inspector__preview-shape--connector::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 0;
  height: 0;
  transform: translateY(-50%);
  pointer-events: none;
}

.style-inspector__preview-shape--connector[data-connector-start="arrow"]::before,
.style-inspector__preview-shape--connector[data-connector-start="triangle"]::before {
  left: 12px;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 8px solid var(--connector-color, #2563eb);
}

.style-inspector__preview-shape--connector[data-connector-start="triangle"]::before {
  border-right-width: 10px;
}

.style-inspector__preview-shape--connector[data-connector-end="arrow"]::before,
.style-inspector__preview-shape--connector[data-connector-end="triangle"]::before {
  padding-right: 0;
}

.style-inspector__preview-shape--connector[data-connector-end="arrow"]::after,
.style-inspector__preview-shape--connector[data-connector-end="triangle"]::after {
  right: 12px;
  border-left: 8px solid var(--connector-color, #2563eb);
  border-right: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}

.style-inspector__preview-shape--connector[data-connector-end="triangle"]::after {
  border-left-width: 10px;
}

.style-inspector__mixed {
  font-size: 13px;
  color: var(--color-text-muted);
  background: var(--color-surface-muted);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  margin-bottom: 12px;
}

.style-inspector fieldset {
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.style-inspector legend {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  padding: 0 6px;
}

.style-inspector__layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 8px;
}

.style-inspector__layout-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.style-inspector__layout-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.style-inspector__layout-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.style-inspector__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.style-inspector__row--align {
  align-items: center;
}

.style-inspector__row label {
  font-size: 13px;
  color: var(--color-text);
}

.style-inspector__color {
  width: 44px;
  height: 28px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0;
  background: var(--color-surface);
  cursor: pointer;
  transition: border-color 120ms ease;
}

.style-inspector__color:hover,
.style-inspector__color:focus-visible {
  border-color: var(--color-accent);
}

.style-inspector__color[data-mixed="true"] {
  background-image: linear-gradient(45deg, rgba(37, 99, 235, 0.18) 25%, transparent 25%, transparent 50%, rgba(37, 99, 235, 0.18) 50%, rgba(37, 99, 235, 0.18) 75%, transparent 75%, transparent);
  background-size: 10px 10px;
}

.style-inspector__slider {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.style-inspector__slider input[type="range"] {
  flex: 1;
}

.style-inspector__slider span {
  min-width: 48px;
  text-align: right;
  font-size: 12px;
  color: var(--color-text-muted);
}

.style-inspector input[type="text"] {
  flex: 1;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  transition: border-color 120ms ease;
}

.style-inspector input[type="text"]:hover,
.style-inspector input[type="text"]:focus-visible {
  border-color: var(--color-accent);
}

/* ------------------------------------------------------------------ */
/* Asset panel                                                         */
/* ------------------------------------------------------------------ */

.asset-panel__body {
  min-height: 150px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.asset-panel__upload {
  display: flex;
  align-items: center;
}

.asset-panel__empty {
  font-size: 13px;
  color: var(--color-text-muted);
  background: var(--color-surface-muted);
  border-radius: 12px;
  padding: 18px 20px;
  text-align: center;
}

.asset-panel__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.asset-panel__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.asset-panel__row:hover,
.asset-panel__row:focus-within {
  border-color: var(--color-accent);
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.14);
}

.asset-panel__row-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.asset-panel__thumbnail-wrapper {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--color-surface-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.asset-panel__thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.asset-panel__thumbnail--video {
  font-size: 18px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  background: linear-gradient(135deg, #1f2937, #334155);
}

.bookmark-overlay {
  background: rgba(15, 23, 42, 0.65);
  border-radius: 14px;
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.32);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: none;
  color: #fff;
}

.bookmark-overlay__media {
  flex: 0 0 42%;
  background: rgba(30, 41, 59, 0.9);
  background-size: cover;
  background-position: center;
  filter: saturate(0.96);
  transition: opacity 200ms ease;
}

.bookmark-overlay__media:not(.has-media) {
  background-image: linear-gradient(135deg, rgba(59, 130, 246, 0.35), rgba(129, 140, 248, 0.35));
}

.bookmark-overlay__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 14px 16px;
  background: rgba(15, 23, 42, 0.85);
}

.bookmark-overlay__title {
  font-size: 14px;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(15, 23, 42, 0.6);
}

.bookmark-overlay__source {
  font-size: 11px;
  letter-spacing: 0.02em;
  color: rgba(226, 232, 240, 0.82);
}

.asset-panel__name {
  font-size: 13px;
  font-weight: 600;
}

.asset-panel__meta {
  font-size: 11px;
  color: var(--color-text-muted);
}

.asset-panel__row-actions {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.asset-panel__row-actions button,
.asset-panel__row-actions a {
  border: 1px solid transparent;
  background: transparent;
  color: var(--color-accent);
  border-radius: 8px;
  font-size: 12px;
  padding: 4px 8px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.asset-panel__row-actions button[data-action="asset-panel#delete"] {
  color: var(--color-danger);
}

.asset-panel__row-actions button:hover,
.asset-panel__row-actions button:focus-visible,
.asset-panel__row-actions a:hover,
.asset-panel__row-actions a:focus-visible {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.18);
}

.asset-panel__pending {
  font-size: 12px;
  color: var(--color-text-muted);
}

.asset-panel__file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.asset-library {
  margin-top: 16px;
  padding: 18px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.asset-library__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.asset-library__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-primary);
}

.asset-library__search input {
  width: 200px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--color-border-subtle);
  background: var(--color-surface-muted);
  color: var(--color-text-primary);
}

.asset-library__filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.asset-library__filter {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--color-border-subtle);
  background: var(--color-surface-muted);
  color: var(--color-text-secondary);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  transition: background 0.2s ease;
}

.asset-library__filter[aria-pressed="true"] {
  background: var(--color-primary-muted);
  color: var(--color-text-primary);
  border-color: transparent;
}

.asset-library__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 12px;
}

.asset-library__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: var(--color-surface-muted);
  color: inherit;
  cursor: pointer;
  transition: border 0.2s ease, transform 0.2s ease;
}

.asset-library__card:hover,
.asset-library__card:focus-visible {
  border-color: var(--color-border);
  transform: translateY(-2px);
}

.asset-library__thumb {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
}

.asset-library__card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-primary);
  text-align: center;
}

.asset-library__card-meta {
  font-size: 11px;
  color: var(--color-text-secondary);
  text-align: center;
}

.asset-library__empty {
  font-size: 13px;
  color: var(--color-text-muted);
  text-align: center;
  padding: 12px;
  border-radius: 10px;
  background: var(--color-surface-muted);
}

.asset-library__help {
  font-size: 12px;
  color: var(--color-text-muted);
}

/* ------------------------------------------------------------------ */
/* Layer panel                                                         */
/* ------------------------------------------------------------------ */

.layer-panel__body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.layer-panel__empty {
  font-size: 13px;
  color: var(--color-text-muted);
  background: var(--color-surface-muted);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

.layer-panel__list,
.layer-panel__nested {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.layer-panel__row {
  padding-left: calc(8px + (var(--layer-depth, 0) * 16px));
}

.layer-panel__row-main {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-surface-strong);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 10px 12px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.layer-panel__row-main:hover,
.layer-panel__row-main:focus-within {
  border-color: var(--color-accent);
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.14);
}

.layer-panel__drag-handle,
.layer-panel__drag-spacer {
  width: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
}

.layer-panel__drag-handle {
  cursor: grab;
  border: none;
  background: none;
}

.layer-panel__drag-spacer {
  cursor: default;
}

.layer-panel__icon {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: var(--color-text);
}

.layer-panel__icon[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

.layer-panel__name {
  cursor: pointer;
  font-size: 13px;
  flex: 1;
}

.layer-panel__row-actions {
  display: inline-flex;
  gap: 8px;
}

.layer-panel__link {
  border: none;
  background: none;
  color: var(--color-accent);
  cursor: pointer;
  font-size: 12px;
  padding: 0;
}

.layer-panel__row--dragging .layer-panel__row-main {
  opacity: 0.7;
  border-style: dashed;
}

/* ------------------------------------------------------------------ */
/* Collaborator panel                                                  */
/* ------------------------------------------------------------------ */

.document-collaborators {
  gap: 14px;
}

.document-collaborators__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.document-collaborators__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--color-surface-strong);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 10px 12px;
}

.document-collaborators__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.document-collaborators__name {
  font-size: 13px;
  font-weight: 600;
}

.document-collaborators__email {
  font-size: 11px;
  color: var(--color-text-muted);
}

.document-collaborators__status {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.document-collaborators__status--active {
  background: rgba(34, 197, 94, 0.16);
  color: #166534;
}

.document-collaborators__status--pending {
  background: rgba(250, 204, 21, 0.18);
  color: #854d0e;
}

.document-collaborators__status--inactive {
  background: rgba(107, 114, 128, 0.18);
  color: #4b5563;
}

.document-collaborators__actions {
  display: inline-flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.document-collaborators__role-select {
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
}

.document-collaborators__role-label {
  font-size: 12px;
  color: var(--color-text-muted);
}

.document-collaborators__remove {
  border: none;
  background: none;
  color: var(--color-danger);
  font-size: 12px;
  cursor: pointer;
}

.document-collaborators__form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--color-surface-muted);
  border-radius: 10px;
}

.document-collaborators__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--color-text);
}

.document-collaborators__field input,
.document-collaborators__field select {
  font-size: 12px;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: #ffffff;
}

.document-collaborators__submit {
  align-self: flex-start;
  background: var(--color-accent);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background 120ms ease;
}

.document-collaborators__submit:hover,
.document-collaborators__submit:focus-visible {
  background: #1d4ed8;
}

/* ------------------------------------------------------------------ */
/* Toast notifications                                                 */
/* ------------------------------------------------------------------ */

.app-toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 320px;
}

.app-toast {
  padding: 12px 16px;
  border-radius: 12px;
  color: #ffffff;
  font-size: 14px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.app-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.app-toast--error {
  background: var(--color-danger);
}

.app-toast--success {
  background: var(--color-success);
}

.app-toast--info {
  background: #2563eb;
}

.app-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.92);
  color: #f8fafc;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 11px;
  line-height: 1.3;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 120ms ease, transform 120ms ease;
  z-index: 3000;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.35);
}

.app-tooltip::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: -6px;
  border-width: 6px;
  border-style: solid;
  border-color: rgba(15, 23, 42, 0.92) transparent transparent transparent;
}

.app-tooltip.is-flipped {
  transform: translateY(4px);
}

.app-tooltip.is-flipped::after {
  bottom: auto;
  top: -6px;
  border-color: transparent transparent rgba(15, 23, 42, 0.92) transparent;
}

.app-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ------------------------------------------------------------------ */
/* Navigation + auth                                                   */
/* ------------------------------------------------------------------ */

.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: #0f172a;
  color: #ffffff;
}

.top-nav a {
  color: inherit;
}

.top-nav__brand {
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.02em;
}

.top-nav__actions {
  display: inline-flex;
  gap: 16px;
  align-items: center;
}

.top-nav__user {
  font-size: 14px;
}

.top-nav__signout {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #ffffff;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 14px;
  cursor: pointer;
}

.flash-container {
  max-width: 960px;
  margin: 16px auto 0;
  padding: 0 24px;
}

.flash {
  margin-bottom: 12px;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 14px;
  color: #0f172a;
  background: #bfdbfe;
}

.flash--alert {
  background: #fee2e2;
  color: #991b1b;
}

.flash--notice {
  background: #dcfce7;
  color: #166534;
}

.auth-container {
  max-width: 360px;
  margin: 48px auto;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
  background: #ffffff;
}

.auth-container h1 {
  margin-bottom: 16px;
  font-size: 22px;
}

.auth-alert {
  margin-bottom: 16px;
  padding: 10px 12px;
  border-radius: 6px;
  background: #fee2e2;
  color: #991b1b;
  font-size: 14px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-field label {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
  color: var(--color-text);
}

.auth-field input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 8px;
  font-size: 14px;
}

.auth-actions {
  display: flex;
  justify-content: flex-end;
}

.auth-actions input[type="submit"] {
  border: none;
  background: var(--color-accent);
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.auth-switch {
  margin-top: 12px;
  font-size: 13px;
  color: #475569;
}
.auth-switch a {
  color: #1e40af;
  text-decoration: underline;
}
.auth-switch a:hover {
  color: #1e3a8a;
}
.style-inspector__row-label {
  font-size: 13px;
  color: var(--color-text);
}

.style-inspector__swatches {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(28px, 1fr));
  gap: 6px;
}

.style-inspector__swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(15, 23, 42, 0.14);
  background: var(--swatch-color);
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease;
}

.style-inspector__swatch:hover,
.style-inspector__swatch:focus-visible {
  transform: scale(1.05);
  border-color: var(--color-accent);
}

.style-inspector__number {
  width: 72px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  font-size: 13px;
}

.style-inspector__number:focus-visible {
  border-color: var(--color-accent);
}

.style-inspector__button-group {
  display: inline-flex;
  gap: 8px;
}

.style-inspector__button {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.style-inspector__button--toggle span[aria-hidden="true"] {
  font-weight: 700;
}

.style-inspector__button--toggle span[aria-hidden="true"] em {
  font-style: italic;
  font-weight: 600;
}

.style-inspector__button--toggle span[aria-hidden="true"] u {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}

.style-inspector__button[aria-pressed="true"],
.style-inspector__button:hover,
.style-inspector__button:focus-visible {
  border-color: var(--color-accent);
  background: rgba(37, 99, 235, 0.12);
  color: var(--color-accent);
}

/* ------------------------------------------------------------------ */
/* Document share & template gallery                                  */
/* ------------------------------------------------------------------ */

.document-share {
  margin: 16px 0 24px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.document-share__actions {
  display: inline-flex;
  gap: 12px;
}

.document-share__button {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.document-share__button:hover,
.document-share__button:focus-visible {
  border-color: var(--color-accent);
  background: rgba(37, 99, 235, 0.08);
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal[hidden] {
  display: none;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.modal__dialog {
  position: relative;
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  background: var(--color-surface-strong);
  border-radius: 16px;
  box-shadow: 0 32px 80px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 12px;
}

.modal__header h2 {
  margin: 0;
  font-size: 18px;
}

.modal__close {
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--color-text-muted);
}

.modal__body {
  padding: 0 24px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal__fieldset {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
}

.modal__fieldset legend {
  font-weight: 600;
  margin-bottom: 4px;
}

.modal__checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.modal__label {
  font-size: 13px;
  font-weight: 600;
}

.modal__fieldset input[type="text"],
.modal__fieldset textarea {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  background: var(--color-surface);
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 8px;
}

.export-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.export-list__item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-surface);
}

.export-list__item--failed {
  border-color: var(--color-danger);
}

.export-list__item--processing {
  border-color: rgba(37, 99, 235, 0.35);
}

.export-list__row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.export-list__title {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.export-list__meta {
  font-size: 12px;
  color: var(--color-text-muted);
}

.export-list__details {
  font-size: 12px;
  color: var(--color-text-muted);
}

.export-list__error {
  margin-top: 6px;
  font-size: 12px;
  color: var(--color-danger);
}

.export-list__actions {
  display: flex;
  align-items: center;
}

.export-list__link {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-accent);
}

.export-list__badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.export-list__badge--queued {
  background: rgba(148, 163, 184, 0.18);
  color: #475569;
}

.export-list__badge--processing {
  background: rgba(37, 99, 235, 0.15);
  color: #1d4ed8;
}

.export-list__badge--completed {
  background: rgba(16, 185, 129, 0.18);
  color: #047857;
}

.export-list__badge--failed {
  background: rgba(239, 68, 68, 0.18);
  color: #b91c1c;
}

.export-list__format {
  font-size: 13px;
  letter-spacing: 0.05em;
}

.export-list__spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(37, 99, 235, 0.2);
  border-top-color: rgba(37, 99, 235, 0.75);
  animation: export-spinner 0.8s linear infinite;
}

.export-list__empty {
  font-size: 13px;
  color: var(--color-text-muted);
}

@keyframes export-spinner {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.documents-index {
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  margin: 24px 0;
}

.documents-index__panel,
.template-gallery {
  background: var(--color-surface-strong);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-panel);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.documents-index__header h2 {
  margin: 0 0 4px;
}

.documents-index__subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--color-text-muted);
}

.documents-index__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.documents-index__item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.documents-index__item-link {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-surface);
  color: inherit;
  text-decoration: none;
  transition: border-color 120ms ease, background 120ms ease;
}

.documents-index__item-link:hover,
.documents-index__item-link:focus-visible {
  border-color: var(--color-accent);
  background: rgba(37, 99, 235, 0.08);
}

.documents-index__item-delete {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: all 120ms ease;
}

.documents-index__item-delete:hover {
  border-color: #dc2626;
  background: #fef2f2;
  color: #dc2626;
}

.documents-index__item-delete:active {
  transform: scale(0.95);
}

.documents-index__item-title {
  font-weight: 600;
}

.documents-index__item-meta {
  font-size: 12px;
  color: var(--color-text-muted);
}

.documents-index__empty {
  font-size: 13px;
  color: var(--color-text-muted);
}

.documents-index__hint {
  font-size: 12px;
  color: var(--color-text-muted);
}

.template-gallery__header {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.template-gallery__subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--color-text-muted);
}

.template-gallery__list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.template-gallery__empty {
  font-size: 13px;
  color: var(--color-text-muted);
}

.template-card {
  border: 1px solid var(--color-border);
  border-radius: 14px;
  background: var(--color-surface);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.template-card__header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.template-card__title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.template-card__title {
  margin: 0;
  font-size: 16px;
}

.template-card__meta {
  margin: 0;
  font-size: 12px;
  color: var(--color-text-muted);
}

.template-card__badge {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.template-card__badge--published {
  background: rgba(34, 197, 94, 0.16);
  color: #047857;
}

.template-card__badge--draft {
  background: rgba(148, 163, 184, 0.2);
  color: #475569;
}

.template-card__description {
  margin: 0;
  font-size: 13px;
  color: var(--color-text);
}

.template-card__footer {
  display: flex;
  justify-content: flex-end;
}

.template-card__button {
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  background: var(--color-surface-muted);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.template-card__button:hover,
.template-card__button:focus-visible {
  border-color: var(--color-accent);
  background: rgba(37, 99, 235, 0.1);
}

body.modal-open {
  overflow: hidden;
}


/* ------------------------------------------------------------------ */
/* Collaboration UI                                                   */
/* ------------------------------------------------------------------ */

.page-switcher {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.page-switcher__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.page-switcher__heading {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.page-switcher__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.page-switcher__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--color-text-muted);
}

.page-switcher__breadcrumbs {
  font-weight: 600;
}

.page-switcher__shortcut {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.08);
  font-size: 11px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.page-switcher__new {
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 6px 10px;
  background: var(--color-surface);
  font-size: 12px;
  cursor: pointer;
}

.page-switcher__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.page-switcher__entry {
  display: flex;
  align-items: center;
  gap: 6px;
}

.page-switcher__entry .page-switcher__item {
  flex: 1 1 auto;
}

.page-switcher__item {
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 8px 12px;
  background: var(--color-surface);
  text-align: left;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.page-switcher__entry.is-active .page-switcher__item,
.page-switcher__item[aria-pressed="true"] {
  border-color: var(--color-accent);
  background: rgba(37, 99, 235, 0.08);
}

.page-switcher__actions {
  display: flex;
  gap: 4px;
}

.page-switcher__actions button {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 11px;
  background: var(--color-muted-surface);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.page-switcher__actions button:hover,
.page-switcher__actions button:focus-visible {
  outline: none;
  border-color: var(--color-border);
  color: var(--color-text);
}

.page-switcher__actions .page-switcher__delete {
  color: var(--color-danger-text);
}

.page-switcher__actions .page-switcher__delete:hover,
.page-switcher__actions .page-switcher__delete:focus-visible {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--color-danger-text);
}

.page-switcher__empty {
  font-size: 12px;
  color: var(--color-text-muted);
}

.comments-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.comments-panel__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.comments-panel__title {
  font-size: 15px;
  font-weight: 600;
}

.comments-panel__meta {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--color-text-muted);
}

.comments-panel__refresh {
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 6px 10px;
  background: var(--color-surface);
  font-size: 12px;
  cursor: pointer;
}

.comments-panel__list {
  min-height: 80px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comments-panel__items {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.comments-panel__item {
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comments-panel__item--resolved {
  border-color: var(--color-success);
}

.comments-panel__item--editing {
  border-style: dashed;
  border-color: var(--color-accent);
  background: rgba(59, 130, 246, 0.05);
}

.comments-panel__item--focused {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.35);
  border-color: rgba(59, 130, 246, 0.65);
}

.comments-panel__item-body {
  font-size: 13px;
}

.comments-panel__item-meta {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--color-text-muted);
}

.comments-panel__item-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.comments-panel__status {
  font-size: 12px;
  color: var(--color-success);
}

.comments-panel__action {
  border: none;
  background: none;
  color: var(--color-accent);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 8px;
  transition: background 120ms ease, color 120ms ease;
}

.comments-panel__action:hover,
.comments-panel__action:focus-visible {
  background: rgba(59, 130, 246, 0.1);
  outline: none;
}

.comments-panel__action--primary {
  background: var(--color-accent);
  color: #fff;
}

.comments-panel__action--primary:hover,
.comments-panel__action--primary:focus-visible {
  background: #1d4ed8;
  color: #fff;
}

.comments-panel__edit-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comments-panel__edit-label {
  font-size: 12px;
  font-weight: 600;
}

.comments-panel__edit-input {
  width: 100%;
  border: 1px solid var(--color-border-strong);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  resize: vertical;
  background: #fff;
}

.comments-panel__form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comments-panel__label {
  font-size: 12px;
  font-weight: 600;
}

.comments-panel__form textarea {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  resize: vertical;
}

.comments-panel__foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.comments-panel__hint {
  font-size: 11px;
  color: var(--color-text-muted);
}

.comments-panel__submit {
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 6px 12px;
  background: var(--color-surface-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.comments-panel__empty {
  font-size: 12px;
  color: var(--color-text-muted);
}

.presence-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  padding: 12px;
}

.presence-overlay__avatars {
  display: flex;
  gap: 8px;
}


.presence-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--avatar-color, #4285f4);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.2);
  pointer-events: auto;
  border: none;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
  position: relative;
}

.presence-avatar:focus-visible {
  outline: 2px solid var(--avatar-color, #4285f4);
  outline-offset: 2px;
}

.presence-avatar:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 12px rgba(15, 23, 42, 0.22);
}

.presence-avatar.is-spotlight {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.4);
}

.presence-avatar.is-following {
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.45);
}

.presence-avatar__initials {
  user-select: none;
}

.presence-avatar__tooltip {
  position: absolute;
  pointer-events: none;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translate(-50%, 4px);
  opacity: 0;
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 11px;
  line-height: 1.3;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 140px;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.35);
  transition: opacity 120ms ease, transform 120ms ease;
  z-index: 20;
}

.presence-avatar__tooltip::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: rgba(15, 23, 42, 0.92) transparent transparent transparent;
}

.presence-avatar__tooltip-name {
  font-weight: 600;
}

.presence-avatar__tooltip-hint {
  font-size: 10px;
  color: rgba(226, 232, 240, 0.9);
}

.presence-avatar:hover .presence-avatar__tooltip,
.presence-avatar:focus-visible .presence-avatar__tooltip {
  opacity: 1;
  transform: translate(-50%, 0);
}

.presence-indicator--spotlight .presence-label {
  background: rgba(37, 99, 235, 0.2);
}

/* ------------------------------------------------------------------ */
/* Command palette                                                     */
/* ------------------------------------------------------------------ */

.command-palette {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.command-palette[hidden] {
  display: none !important;
}

.command-palette__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(6px);
}

.command-palette__dialog {
  position: relative;
  width: min(640px, 90vw);
  max-height: 70vh;
  background: rgba(15, 23, 42, 0.95);
  border-radius: 16px;
  box-shadow: 0 40px 120px rgba(15, 23, 42, 0.4);
  border: 1px solid rgba(148, 163, 184, 0.18);
  padding: 16px;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.command-palette__input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  padding: 10px 14px;
}

.command-palette__prompt {
  font-size: 12px;
  color: rgba(148, 163, 184, 0.8);
  font-weight: 600;
  letter-spacing: 0.05em;
}

.command-palette__input {
  flex: 1;
  background: transparent;
  border: none;
  color: #f8fafc;
  font-size: 16px;
  outline: none;
}

.command-palette__close {
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(30, 41, 59, 0.9);
  color: rgba(226, 232, 240, 0.85);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

.command-palette__body {
  min-height: 200px;
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.85);
}

.command-palette__list {
  list-style: none;
  margin: 0;
  padding: 8px 0;
}

.command-palette__group {
  padding: 6px 18px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(148, 163, 184, 0.65);
}

.command-palette__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  font-size: 15px;
  cursor: pointer;
  color: rgba(226, 232, 240, 0.9);
}

.command-palette__item:hover,
.command-palette__item.is-active {
  background: rgba(37, 99, 235, 0.24);
  color: #ffffff;
}

.command-palette__item-shortcut {
  font-size: 12px;
  color: rgba(226, 232, 240, 0.7);
}

.command-palette__empty {
  text-align: center;
  padding: 40px 18px;
  color: rgba(148, 163, 184, 0.7);
  font-size: 14px;
}
.style-inspector__preview-shape--connector[data-connector-start="none"]::before,
.style-inspector__preview-shape--connector[data-connector-end="none"]::after {
  display: none;
}

/* ------------------------------------------------------------------ */
/* Context Menu                                                       */
/* ------------------------------------------------------------------ */

.context-menu {
  position: fixed;
  z-index: 9999;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  min-width: 200px;
  max-width: 280px;
  display: none;
  overflow: hidden;
}

.context-menu[aria-hidden="false"] {
  display: block;
}

.context-menu__content {
  list-style: none;
  margin: 0;
  padding: 8px 0;
}

.context-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  font-size: 14px;
  color: rgba(226, 232, 240, 0.9);
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background 120ms ease;
}

.context-menu__item:hover,
.context-menu__item:focus-visible,
.context-menu__item.is-active {
  background: rgba(37, 99, 235, 0.2);
  color: #ffffff;
  outline: none;
}

.context-menu__item--dangerous {
  color: rgba(248, 113, 113, 0.9);
}

.context-menu__item--dangerous:hover,
.context-menu__item--dangerous:focus-visible,
.context-menu__item--dangerous.is-active {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.context-menu__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  font-size: 12px;
}

.context-menu__label {
  flex: 1;
  font-weight: 500;
}

.context-menu__shortcut {
  font-size: 11px;
  color: rgba(148, 163, 184, 0.7);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  background: rgba(30, 41, 59, 0.6);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(71, 85, 105, 0.3);
}

.context-menu__separator {
  margin: 6px 14px;
  border: none;
  border-top: 1px solid rgba(148, 163, 184, 0.15);
  background: none;
}

/* Override Lexxy editor default min-height for compact text fields */
/* Lexxy has a default min-height of ~268.75px which is too tall for tldraw-style text */
lexxy-editor .lexxy-editor__content {
  min-height: 1em !important;
  height: auto !important;
}

lexxy-editor .tiptap,
lexxy-editor [contenteditable],
lexxy-editor .ProseMirror {
  min-height: 1em !important;
  height: auto !important;
}

/* Template variable syntax highlighting for {{variable}} placeholders */
/* Used in PromptNode inline editors - matches Weavy.ai style */
.template-variable {
  background-color: #dbeafe; /* blue-100 */
  color: #1d4ed8;            /* blue-700 */
  border-radius: 3px;
  padding: 0 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
  white-space: nowrap;
}

/* Hover state for template variables */
.template-variable:hover {
  background-color: #bfdbfe; /* blue-200 */
}

/* Dark mode support for template variables */
@media (prefers-color-scheme: dark) {
  .template-variable {
    background-color: #1e3a5f;
    color: #93c5fd; /* blue-300 */
  }
  .template-variable:hover {
    background-color: #1e40af;
  }
}

/* Preview text in node body (truncated to ~50 chars) */
.node-editor-placeholder {
  color: #6b7280; /* gray-500 */
  font-size: 12px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* AggregatorNode preview - show full content with word wrap */
[id^="aggregator-node-preview-"] {
  overflow-y: auto !important;
  overflow-x: hidden !important;
  text-overflow: clip !important;
  white-space: normal !important;
  word-wrap: break-word !important;
  word-break: break-word !important;
}

/* Waypoint handles for connector editing */
.waypoint-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2001;
}

.waypoint-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #fff;
  border: 2px solid #2563eb;
  border-radius: 50%;
  cursor: move;
  pointer-events: auto;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: transform 0.15s ease;
}

.waypoint-handle:hover {
  transform: translate(-50%, -50%) scale(1.2);
  background: #2563eb;
  border-color: #1d4ed8;
}

.waypoint-handle:active {
  transform: translate(-50%, -50%) scale(1.1);
  background: #1d4ed8;
  border-color: #1e40af;
}

.waypoint-handle__remove {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid #ef4444;
  background: #fff5f5;
  color: #b91c1c;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
  cursor: pointer;
  pointer-events: auto;
  padding: 0;
}

.waypoint-handle__remove::before {
  content: '×';
  display: block;
}

.waypoint-handle__remove:hover {
  background: #fee2e2;
  border-color: #dc2626;
}

.waypoint-add-button {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #10b981;
  border: 1px solid #059669;
  color: #fff;
  font-size: 12px;
  line-height: 14px;
  text-align: center;
  cursor: pointer;
  pointer-events: auto;
  transform: translate(-50%, -50%);
}

.waypoint-add-button::before {
  content: '+';
  display: block;
}

.waypoint-add-button:hover {
  background: #059669;
  border-color: #047857;
}

/* ========================================
   PORT SYSTEM - LITEGRAPH-STYLE PORTS
   ======================================== */

/* Port overlays - shown when shape is selected */
.port-overlay {
  position: absolute;
  border-radius: 50%;
  pointer-events: auto;
  cursor: pointer;
  z-index: 100;
  transition: transform 0.1s ease-out;
}

.port-overlay:hover {
  transform: translate(-50%, -50%) scale(1.3);
}

.port-overlay--input {
  /* Green color for input ports - set inline via JavaScript */
}

.port-overlay--output {
  /* Blue color for output ports - set inline via JavaScript */
}

/* Port preview - ghost port shown during connector creation */
.port-preview {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1000;
  /* Colors and size set inline via JavaScript */
}

@keyframes port-preview-pulse {
  0%, 100% {
    opacity: 0.5;
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    opacity: 0.8;
    transform: translate(-50%, -50%) scale(1.2);
  }
}

/* ========================================
   NANOBANANA NODE - REAL-TIME STATUS
   ======================================== */

/* Spinner animation */
@keyframes nano-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.nano-spinner {
  animation: nano-spin 1s linear infinite;
  transform-origin: center;
}

/* Progress bar animation */
@keyframes nano-progress-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.nano-progress-bar {
  animation: nano-progress-pulse 1.5s ease-in-out infinite;
  transition: width 0.3s ease-out;
}

/* Node running state - glowing border */
.node-running rect:first-child {
  stroke: #4ade80;
  stroke-width: 2;
  animation: node-running-glow 1.5s ease-in-out infinite;
}

@keyframes node-running-glow {
  0%, 100% {
    filter: drop-shadow(0 0 4px rgba(74, 222, 128, 0.4));
  }
  50% {
    filter: drop-shadow(0 0 12px rgba(74, 222, 128, 0.8));
  }
}

/* Status overlay visibility */
.nano-status-overlay {
  pointer-events: none;
}

/* Success state */
.node-success rect:first-child {
  stroke: #4ade80;
  stroke-width: 2;
}

/* Error state */
.node-error rect:first-child {
  stroke: #ef4444;
  stroke-width: 2;
  animation: node-error-pulse 0.5s ease-in-out 3;
}

@keyframes node-error-pulse {
  0%, 100% {
    filter: drop-shadow(0 0 4px rgba(239, 68, 68, 0.4));
  }
  50% {
    filter: drop-shadow(0 0 12px rgba(239, 68, 68, 0.8));
  }
}
