/**
 * SyncInk - Design System
 * Dark-first, editorial-minimalist
 */

/* ─────────────────────────────────────────────────────────────
   CSS Custom Properties (Design Tokens)
   ───────────────────────────────────────────────────────────── */

:root {
  /* ─── Backgrounds ─── */
  --color-bg-primary:       #0B0B0F;
  --color-bg-surface:       #14141A;
  --color-bg-surface-2:     #1C1C24;
  --color-bg-surface-3:     #24242E;
  --color-bg-elevated:      #1A1A22;

  /* ─── Borders ─── */
  --color-border-subtle:    #2A2A36;
  --color-border-medium:    #3A3A48;

  /* ─── Text ─── */
  --color-text-primary:     #EAEAF0;
  --color-text-secondary:   #A0A0B0;
  --color-text-muted:       #606070;

  /* ─── Accent ─── */
  --color-accent:           #0891b2;
  --color-accent-hover:     #7C7FF7;
  --color-accent-soft:      rgba(99, 102, 241, 0.12);
  --color-accent-glow:      rgba(99, 102, 241, 0.25);

  /* ─── Ink Colors (stroke palette) ─── */
  --ink-white:    #FFFFFF;
  --ink-black:    #1A1A2E;
  --ink-red:      #EF4444;
  --ink-blue:     #3B82F6;
  --ink-green:    #22C55E;
  --ink-yellow:   #EAB308;
  --ink-orange:   #F97316;
  --ink-cyan:     #06B6D4;
  --ink-pink:     #EC4899;
  --ink-purple:   #A855F7;

  /* ─── Semantic ─── */
  --color-success:    #22C55E;
  --color-warning:    #EAB308;
  --color-error:      #EF4444;
  --color-info:       #06B6D4;

  /* ─── Spacing Scale (4px base) ─── */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;

  /* ─── Border Radius ─── */
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  20px;
  --radius-full: 9999px;

  /* ─── Shadows ─── */
  --shadow-sm:    0 2px 8px rgba(0,0,0,0.2);
  --shadow-md:    0 4px 16px rgba(0,0,0,0.3);
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.4);
  --shadow-glow:  0 0 20px var(--color-accent-glow);

  /* ─── Transitions ─── */
  --transition-fast:   0.1s ease;
  --transition-normal: 0.2s ease;
  --transition-slow:   0.35s cubic-bezier(0.4, 0, 0.2, 1);

  /* ─── Z-Index Scale ─── */
  --z-canvas:    1;
  --z-grid:      2;
  --z-strokes:   10;
  --z-cursors:   50;
  --z-toolbar:   100;
  --z-panel:     200;
  --z-modal:     300;
  --z-toast:     400;

  /* ─── Font Stack ─── */
  --font-sans:  'DM Sans', system-ui, -apple-system, sans-serif;
  --font-mono:  'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

  /* ─── Type Scale ─── */
  --text-xs:   11px;
  --text-sm:   13px;
  --text-base: 15px;
  --text-lg:   17px;
  --text-xl:   22px;
  --text-2xl:  28px;
}

/* ─── Light Theme Override ─── */
[data-theme="light"] {
  --color-bg-primary:    #F8F8FC;
  --color-bg-surface:    #FFFFFF;
  --color-bg-surface-2:  #F0F0F6;
  --color-bg-surface-3:  #E8E8F0;
  --color-bg-elevated:   #FFFFFF;
  --color-border-subtle: #E0E0EA;
  --color-border-medium: #C0C0D0;
  --color-text-primary:  #1A1A2E;
  --color-text-secondary:#5A5A6E;
  --color-text-muted:    #9A9AAE;
}

/* ─────────────────────────────────────────────────────────────
   Base Styles
   ───────────────────────────────────────────────────────────── */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--color-text-primary);
  background: var(--color-bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  /* Disable pull-to-refresh on mobile */
  overscroll-behavior: none;
  /* Disable text selection during drawing */
  user-select: none;
  -webkit-user-select: none;
  /* Disable iOS callout */
  -webkit-touch-callout: none;
}

/* ─────────────────────────────────────────────────────────────
   Canvas Container
   ───────────────────────────────────────────────────────────── */

.canvas-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: var(--z-canvas);

  /* Dot grid background */
  background-color: var(--color-bg-primary);
  background-image: radial-gradient(circle, var(--color-border-subtle) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: 0 0;

  /* Prevent touch actions (we handle them via pointer events) */
  touch-action: none;

  /* Cursor */
  cursor: crosshair;
}

/* Hide grid in light theme or when grid is disabled */
[data-theme="light"] .canvas-container {
  background-image: radial-gradient(circle, var(--color-border-subtle) 1px, transparent 1px);
}

.canvas-container.grid-hidden {
  background-image: none;
}

.canvas-container.grid-lines {
  background-image:
    linear-gradient(var(--color-border-subtle) 1px, transparent 1px),
    linear-gradient(90deg, var(--color-border-subtle) 1px, transparent 1px);
}

/* Canvas elements */
.canvas-container canvas {
  position: absolute;
  top: 0;
  left: 0;
  /* Will be sized via JavaScript */
}

/* ─────────────────────────────────────────────────────────────
   Toast Notifications
   ───────────────────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  top: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border-medium);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  min-width: 200px;
  max-width: 400px;

  /* Animation */
  opacity: 0;
  transform: translateY(-20px);
  animation: toast-in var(--transition-normal) forwards;
}

.toast.toast-out {
  animation: toast-out var(--transition-normal) forwards;
}

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

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

/* Toast variants */
.toast.toast-success {
  border-color: var(--color-success);
}

.toast.toast-error {
  border-color: var(--color-error);
}

.toast.toast-info {
  border-color: var(--color-info);
}

/* ─────────────────────────────────────────────────────────────
   Modal Container
   ───────────────────────────────────────────────────────────── */

.modal-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.modal-container.active {
  display: flex;
  pointer-events: all;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  opacity: 0;
  animation: fade-in var(--transition-normal) forwards;
}

.modal {
  position: relative;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border-medium);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 90%;
  max-height: 90%;
  overflow: auto;

  /* Animation */
  opacity: 0;
  transform: scale(0.9);
  animation: modal-in var(--transition-normal) forwards;
}

@keyframes fade-in {
  to { opacity: 1; }
}

@keyframes modal-in {
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ─────────────────────────────────────────────────────────────
   Accessibility
   ───────────────────────────────────────────────────────────── */

/* Focus visible ring */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  box-shadow: var(--shadow-glow);
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode */
@media (prefers-contrast: more) {
  :root {
    --color-border-subtle: #FFFFFF;
    --color-border-medium: #FFFFFF;
  }
}

/* ─────────────────────────────────────────────────────────────
   Utility Classes
   ───────────────────────────────────────────────────────────── */

.hidden {
  display: none !important;
}

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

/* ─────────────────────────────────────────────────────────────
   Toolbar
   ───────────────────────────────────────────────────────────── */

.toolbar {
  position: fixed;
  top: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toolbar);
  max-width: calc(100vw - 32px);

  display: flex;
  align-items: center;
  gap: 0;
  padding: var(--space-2);

  /* Unified pill */
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border-medium);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(20px);

  /* Animation */
  opacity: 0;
  animation: toolbar-in 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes toolbar-in {
  to { opacity: 1; }
}

/* Groups: logical sections inside the unified pill */
.toolbar-group {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 4px;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
}

/* Colored vertical separator after each group (except last) */
.toolbar-group:not(:last-child) {
  padding-right: 10px;
  margin-right: 6px;
}

.toolbar-group:not(:last-child)::after {
  content: '';
  position: absolute;
  right: 0;
  top: 5px;
  bottom: 5px;
  width: 2px;
  border-radius: 1px;
  background: var(--group-sep-color, var(--color-border-subtle));
}

.toolbar-group--tools   { --group-sep-color: rgba(99, 102, 241, 0.45); }
.toolbar-group--palette { --group-sep-color: rgba(6, 182, 212, 0.45); }
.toolbar-group--history { --group-sep-color: rgba(168, 85, 247, 0.45); }
.toolbar-group--danger  { --group-sep-color: rgba(239, 68, 68, 0.45); }
.toolbar-group--export  { --group-sep-color: rgba(16, 185, 129, 0.45); }
/* config is last — no separator needed */

.toolbar-section {
  display: flex;
  align-items: center;
  gap: 2px;
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--color-border-subtle);
  margin: 0 2px;
}

.tool-button {
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tool-button svg {
  width: 18px;
  height: 18px;
}

.tool-button:hover {
  background: var(--color-bg-surface-2);
  color: var(--color-text-primary);
}

.tool-button.active {
  background: var(--color-accent);
  color: #FFFFFF;
}

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

/* ─────────────────────────────────────────────────────────────
   Color Picker
   ───────────────────────────────────────────────────────────── */

.color-picker {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.color-swatch {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
}

.color-swatch:hover {
  transform: scale(1.1);
}

.color-swatch.active {
  border-color: var(--color-text-primary);
  box-shadow: 0 0 0 2px var(--color-bg-elevated),
              0 0 0 4px var(--color-text-primary),
              inset 0 0 0 1px rgba(0,0,0,0.1);
}

/* ─────────────────────────────────────────────────────────────
   Stroke Width Selector
   ───────────────────────────────────────────────────────────── */

.stroke-width-selector {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.width-button {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.width-button:hover {
  background: var(--color-bg-surface-2);
}

.width-button.active {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.width-preview {
  transition: all var(--transition-fast);
}

/* ─────────────────────────────────────────────────────────────
   Responsive Toolbar
   ───────────────────────────────────────────────────────────── */

/* ─── Responsive: compact toolbar at medium screens ───────────────────────── */

/* 1400px: slightly smaller palette to give the toolbar room */
@media (max-width: 1400px) {
  .color-swatch {
    width: 22px;
    height: 22px;
  }
  .color-picker {
    gap: 4px;
  }
  .stroke-width-selector {
    gap: 4px;
  }
}

/* 1366px: move user list below toolbar so it never overlaps */
@media (max-width: 1366px) {
  .ul-panel {
    top: 82px;
    right: 16px;
  }
}

/* 1200px: compact buttons + scrollable toolbar */
@media (max-width: 1200px) {
  .toolbar {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    justify-content: flex-start;
  }
  .toolbar::-webkit-scrollbar { display: none; }

  .toolbar-group { flex-shrink: 0; }

  .tool-button {
    width: 36px;
    height: 36px;
  }
  .color-swatch {
    width: 18px;
    height: 18px;
  }
  .width-button {
    width: 28px;
    height: 28px;
  }
  .color-picker  { gap: 3px; }
  .stroke-width-selector { gap: 3px; }
  .toolbar-group:not(:last-child) {
    padding-right: 6px;
    margin-right: 4px;
  }
}

/* 1024px: tighter still + shrink user avatars */
@media (max-width: 1024px) {
  .tool-button {
    width: 32px;
    height: 32px;
  }
  .tool-button svg {
    width: 15px;
    height: 15px;
  }
  .color-swatch {
    width: 16px;
    height: 16px;
  }
  .width-button {
    width: 24px;
    height: 24px;
  }
  .color-picker  { gap: 2px; }
  .stroke-width-selector { gap: 2px; }
  .toolbar-divider { margin: 0 1px; }
  .toolbar-group:not(:last-child) {
    padding-right: 4px;
    margin-right: 2px;
  }
  .toolbar { padding: 4px 6px; }

  /* Shrink user list avatars so they don't clash with toolbar */
  .ul-avatar__circle {
    width: 26px;
    height: 26px;
    font-size: 10px;
  }
  .ul-panel {
    top: 10px;
    right: 12px;
  }
}

/* 900px: tablet portrait – aggressive compaction so toolbar fits in one row */
@media (max-width: 900px) {
  /* Hide less-essential buttons to reduce toolbar width */
  #fill-toggle,
  #mermaid-button { display: none; }
  .tool-button {
    width: 26px;
    height: 26px;
  }
  .tool-button svg {
    width: 13px;
    height: 13px;
  }
  .color-swatch {
    width: 12px;
    height: 12px;
  }
  .width-button {
    width: 20px;
    height: 20px;
  }
  /* Hide stroke-width-selector to save ~80px – not needed on touch */
  .stroke-width-selector {
    display: none;
  }
  .color-picker { gap: 2px; }
  .toolbar-divider { display: none; }
  .toolbar-group:not(:last-child) {
    padding-right: 2px;
    margin-right: 1px;
  }
  .toolbar {
    padding: 3px 4px;
  }

  /* Even smaller avatars */
  .ul-avatar__circle {
    width: 22px;
    height: 22px;
    font-size: 9px;
  }
  .ul-avatar__you-dot {
    width: 6px;
    height: 6px;
  }
  .ul-panel {
    top: 8px;
    right: 10px;
  }
}

/* 768px: single scrollable row — no wrap */
@media (max-width: 768px) {
  .toolbar {
    flex-wrap: nowrap;
    justify-content: flex-start;
    max-width: calc(100vw - 24px);
  }
}

/* ─────────────────────────────────────────────────────────────
   Remote Cursors
   ───────────────────────────────────────────────────────────── */

.remote-cursor {
  position: absolute;
  pointer-events: none;
  z-index: var(--z-cursors);
  transition: left 80ms linear, top 80ms linear;
  display: none;
}

.remote-cursor svg {
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.remote-cursor-name {
  position: absolute;
  left: 24px;
  top: 0;
  padding: var(--space-1) var(--space-2);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--color-text-primary);
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}

/* ─────────────────────────────────────────────────────────────
   Room Modal
   ───────────────────────────────────────────────────────────── */

@keyframes rm-backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes rm-modal-in {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

@keyframes rm-backdrop-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@keyframes rm-shake {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-5px); }
  75%       { transform: translateX(5px); }
}

.rm-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background: rgba(7, 7, 11, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: rm-backdrop-in 0.25s ease forwards;
}

.rm-backdrop--out {
  animation: rm-backdrop-out 0.26s ease forwards;
}

.rm-modal {
  width: min(640px, 100%);
  max-height: calc(100dvh - 48px);
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255,255,255,0.04);
  overflow-y: auto;
  animation: rm-modal-in 0.3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* ─── Header ─── */

.rm-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-10) var(--space-10) var(--space-6);
  border-bottom: 1px solid var(--color-border-subtle);
}

.rm-logo-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.rm-logo-icon {
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}

.rm-logo-name {
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text-primary);
}

.rm-tagline {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: center;
}

/* ─── Body ─── */

.rm-body {
  padding: var(--space-6) var(--space-8);
  display: flex;
  flex-direction: column;
}

/* ─── Divider ─── */

.rm-or {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin: var(--space-4) 0;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.rm-or::before,
.rm-or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border-subtle);
}

/* ─── Cards ─── */

.rm-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-6);
  background: var(--color-bg-surface-2);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast),
              box-shadow var(--transition-fast), transform var(--transition-fast);
  width: 100%;
  font-family: var(--font-sans);
  color: var(--color-text-primary);
}

.rm-card--create:hover,
.rm-card--create:focus-visible {
  border-color: var(--color-accent);
  background: var(--color-bg-surface-3);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
  transform: translateY(-1px);
  outline: none;
}

.rm-card--create:active {
  transform: translateY(0);
}

/* Join card: columna, no clickeable */
.rm-card--join {
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-4);
  cursor: default;
}

.rm-card__icon {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-accent-soft);
  border-radius: var(--radius-md);
  color: var(--color-accent);
}

.rm-card__content {
  flex: 1;
  min-width: 0;
}

.rm-card__title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 2px;
}

.rm-card__desc {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: 1.4;
}

.rm-card__arrow {
  flex-shrink: 0;
  color: var(--color-text-muted);
  transition: transform var(--transition-fast), color var(--transition-fast);
}

.rm-card--create:hover .rm-card__arrow {
  color: var(--color-accent);
  transform: translateX(2px);
}

/* ─── Join card interior ─── */

.rm-join-header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

/* ─── Botón pegar (acción principal en tablet) ─── */

.rm-paste-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  height: 52px;
  background: var(--color-accent-soft);
  border: 1.5px dashed var(--color-accent);
  border-radius: var(--radius-md);
  color: var(--color-accent);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast),
              transform var(--transition-fast), box-shadow var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.rm-paste-btn:hover,
.rm-paste-btn:focus-visible {
  background: rgba(99, 102, 241, 0.18);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
  outline: none;
}

.rm-paste-btn:active {
  transform: scale(0.98);
}

/* Hint: cuando detectamos un link en clipboard */
.rm-paste-btn--hint {
  background: rgba(99, 102, 241, 0.15);
  border-style: solid;
  box-shadow: 0 0 0 3px var(--color-accent-soft);
  animation: rm-pulse 1.8s ease infinite;
}

@keyframes rm-pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--color-accent-soft); }
  50%       { box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.08); }
}

/* ─── Input manual (alternativa al pegar) ─── */

.rm-join-manual {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.rm-join-manual__label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.rm-join-row {
  display: flex;
  gap: var(--space-2);
}

/* ─── Input ─── */

.rm-input {
  flex: 1;
  height: 48px;
  padding: 0 var(--space-4);
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border-medium);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  /* Evitar zoom en iOS al hacer focus */
  font-size: max(16px, var(--text-sm));
}

.rm-input::placeholder {
  color: var(--color-text-muted);
}

.rm-input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}

.rm-input--error {
  border-color: var(--color-error) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
  animation: rm-shake 0.35s ease;
}

/* ─── Botones secundarios ─── */

.rm-btn-secondary {
  height: 48px;
  padding: 0 var(--space-5);
  background: var(--color-accent);
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition-fast), transform var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.rm-btn-secondary:hover {
  background: var(--color-accent-hover);
}

.rm-btn-secondary:active {
  transform: scale(0.97);
}

/* ─── Share step ─── */

.rm-share {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) 0 var(--space-2);
  text-align: center;
}

.rm-share__check {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(34, 197, 94, 0.1);
  border-radius: 50%;
}

.rm-share__title {
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text-primary);
}

.rm-share__subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.rm-share__url-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  background: var(--color-bg-surface-2);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
}

.rm-share__url {
  flex: 1;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.rm-share__copy-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-surface-3);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast),
              border-color var(--transition-fast);
}

.rm-share__copy-btn:hover {
  background: var(--color-accent-soft);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.rm-share__copy-btn--copied {
  background: rgba(34, 197, 94, 0.12);
  border-color: var(--color-success);
  color: var(--color-success);
}

/* ─── Botones de acción en share step ─── */

.rm-share__actions {
  display: flex;
  gap: var(--space-3);
  width: 100%;
  justify-content: center;
  margin-top: var(--space-2);
}

.rm-btn-primary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: 52px;
  padding: 0 var(--space-6);
  background: var(--color-accent);
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast),
              box-shadow var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.rm-btn-primary:hover {
  background: var(--color-accent-hover);
  box-shadow: 0 4px 16px var(--color-accent-glow);
  transform: translateY(-1px);
}

.rm-btn-primary:active {
  transform: translateY(0);
}

/* Botón compartir nativo (share sheet en iOS/Android) */
.rm-btn-share {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: 52px;
  padding: 0 var(--space-5);
  background: transparent;
  border: 1.5px solid var(--color-border-medium);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.rm-btn-share:hover {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.rm-btn-share:active {
  transform: scale(0.97);
}

/* ─── Footer ─── */

.rm-footer {
  padding: var(--space-4) var(--space-8);
  border-top: 1px solid var(--color-border-subtle);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-align: center;
}

/* ─── Responsive tablet (hasta 768px) ─── */

@media (max-width: 768px) {
  .rm-share__actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .rm-btn-primary,
  .rm-btn-share {
    width: 100%;
    justify-content: center;
  }
}

/* ─── Responsive móvil (hasta 540px) → sheet desde abajo ─── */

@media (max-width: 540px) {
  .rm-backdrop {
    padding: 0;
    align-items: flex-end;
  }

  .rm-modal {
    width: 100%;
    max-height: 92dvh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }

  .rm-header {
    padding: var(--space-8) var(--space-6) var(--space-4);
  }

  .rm-body {
    padding: var(--space-5) var(--space-5);
  }

  .rm-footer {
    padding: var(--space-3) var(--space-5) var(--space-6);
  }

  .rm-join-row {
    flex-direction: column;
  }

  .rm-btn-secondary {
    width: 100%;
  }

  .rm-paste-btn {
    height: 60px;
    font-size: var(--text-lg);
  }
}

/* ─── Brand — wordmark top-left ─────────────────────────────────────────────── */

.brand {
  position: fixed;
  top: 24px;
  left: 16px;
  height: 56px;        /* same height as toolbar pill */
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  user-select: none;
}

.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand__name {
  font-size: clamp(12px, 1.3vw, 20px);
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--color-text-primary, #f1f5f9);
}

.brand__sub {
  font-size: clamp(9px, 0.85vw, 13px);
  font-weight: 500;
  letter-spacing: 0.1px;
  color: #0891b2;
  margin-top: 3px;
  text-decoration: none;
  pointer-events: all;
  cursor: pointer;
}

.brand__sub:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Hide subtitle earlier so it never crowds the toolbar */
@media (max-width: 1400px) {
  .brand__sub { display: none; }
}
/* Hide brand on anything tablet-sized — toolbar needs the full width */
@media (max-width: 1366px) {
  .brand { display: none; }
}

/* Status indicators container — bottom-right corner, above zoom controls */
.brand__indicators {
  position: fixed;
  bottom: 70px;
  right: 20px;
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.brand__save {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.09);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  opacity: 0;
  transform: translateX(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
}

.brand__save--visible {
  opacity: 1;
  transform: translateX(0);
}

.brand__save-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-text-muted, #64748b);
  flex-shrink: 0;
}

.brand__save-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-muted, #94a3b8);
}

/* State: saving */
.brand__save--saving .brand__save-dot {
  background: #f59e0b;
  animation: brand-pulse 0.8s ease-in-out infinite;
}
.brand__save--saving .brand__save-label { color: #f59e0b; }

/* State: saved */
.brand__save--saved .brand__save-dot { background: #22c55e; }
.brand__save--saved .brand__save-label { color: #22c55e; }

/* State: error */
.brand__save--error .brand__save-dot { background: #ef4444; }
.brand__save--error .brand__save-label { color: #ef4444; }

@keyframes brand-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* ─── User List — panel top-right ───────────────────────────────────────────── */

.ul-panel {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 100;
  pointer-events: none;
  user-select: none;
}

.ul-avatars {
  display: flex;
  flex-direction: row-reverse; /* último unido a la derecha */
  align-items: center;
  gap: -6px; /* overlap */
}

/* Para el overlap usamos margin negativo en lugar de gap negativo */
.ul-avatars {
  gap: 0;
}

.ul-avatar {
  position: relative;
  margin-left: -6px;
  pointer-events: all;
  cursor: default;
}

.ul-avatar:first-child {
  margin-left: 0;
}

.ul-avatar__circle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  border: 2px solid rgba(15, 23, 42, 0.8);
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  transition: transform 0.15s ease, z-index 0s;
}

.ul-avatar:hover .ul-avatar__circle {
  transform: translateY(-3px) scale(1.1);
  z-index: 10;
  border-color: rgba(255,255,255,0.25);
}

/* Punto blanco debajo del propio avatar */
.ul-avatar__you-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid rgba(15,23,42,0.8);
}

/* Tooltip nativo via [title] — en móvil no funciona, no necesitamos más */

/* ─── Brand — connection indicator ─────────────────────────────────────────── */

.brand__conn {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  pointer-events: all;
  cursor: default;
  transition: background 0.3s ease;
}

.brand__conn--connecting  { background: #f59e0b; animation: brand-pulse 1s ease-in-out infinite; }
.brand__conn--connected   { background: #22c55e; }
.brand__conn--disconnected{ background: #ef4444; }
.brand__conn--reconnecting{ background: #f59e0b; animation: brand-pulse 0.6s ease-in-out infinite; }

/* ─── Zoom Controls ─────────────────────────────────────────────────────────── */

.zc-panel {
  position: fixed;
  bottom: 24px;
  right: 20px;
  z-index: var(--z-toolbar);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border-medium);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(12px);
}

.zc-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.zc-btn:hover {
  background: var(--color-bg-surface-2);
  color: var(--color-text-primary);
}

.zc-level {
  height: 32px;
  min-width: 52px;
  padding: 0 var(--space-2);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  text-align: center;
}

.zc-level:hover {
  background: var(--color-bg-surface-2);
  color: var(--color-text-primary);
}

.zc-sep {
  width: 1px;
  height: 20px;
  background: var(--color-border-subtle);
  margin: 0 2px;
}

/* ─── Room Modal — name row ──────────────────────────────────────────────────── */

.rm-name-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-5) var(--space-8);
  border-bottom: 1px solid var(--color-border-subtle);
}

.rm-name-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
}

.rm-name-input {
  width: 100%;
}

/* ─── Room Modal — recent rooms ──────────────────────────────────────────────── */

.rm-recent {
  padding: var(--space-4) var(--space-8);
  border-bottom: 1px solid var(--color-border-subtle);
}

.rm-recent__label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.rm-recent__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.rm-recent__chip {
  height: 30px;
  padding: 0 var(--space-3);
  background: var(--color-bg-surface-3);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-full);
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast),
              background var(--transition-fast);
  white-space: nowrap;
}

.rm-recent__chip:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: var(--color-accent-soft);
}

/* ─── Tool button danger variant ─────────────────────────────────────────────── */

.tool-button--danger:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
}

/* ─────────────────────────────────────────────────────────────
   Presentation Mode
   ───────────────────────────────────────────────────────────── */

body.presentation-mode .toolbar,
body.presentation-mode .brand,
body.presentation-mode .brand__indicators,
body.presentation-mode .ul-panel,
body.presentation-mode .zc-panel,
body.presentation-mode .minimap-panel,
body.presentation-mode #toolbar-container {
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-slow);
}

body.presentation-mode .canvas-container {
  cursor: none;
}

/* ─────────────────────────────────────────────────────────────
   Shortcuts Panel
   ───────────────────────────────────────────────────────────── */

.sp-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.sp-overlay--visible {
  opacity: 1;
  pointer-events: all;
}

.sp-panel {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  width: min(640px, 92vw);
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.sp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}

.sp-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text-primary);
}

.sp-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-surface-2);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
}

.sp-close svg { width: 16px; height: 16px; }
.sp-close:hover { background: var(--color-bg-surface-3); color: var(--color-text-primary); }

.sp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-5);
}

.sp-group-title {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

.sp-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-1) 0;
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
}

.sp-row kbd {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  background: var(--color-bg-surface-3);
  border: 1px solid var(--color-border-medium);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-primary);
  white-space: nowrap;
  min-width: 24px;
  justify-content: center;
}

/* ─────────────────────────────────────────────────────────────
   Context Menu
   ───────────────────────────────────────────────────────────── */

.ctx-menu {
  position: fixed;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-1);
  z-index: var(--z-toast);
  min-width: 160px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transform: scale(0.95);
  transform-origin: top left;
  transition: opacity 0.1s ease, transform 0.1s ease;
}

.ctx-menu--visible {
  opacity: 1;
  pointer-events: all;
  transform: scale(1);
}

.ctx-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.ctx-item:hover {
  background: var(--color-bg-surface-2);
  color: var(--color-text-primary);
}

.ctx-item--danger:hover {
  background: rgba(239,68,68,0.1);
  color: var(--color-error);
}

.ctx-separator {
  height: 1px;
  background: var(--color-border-subtle);
  margin: var(--space-1) 0;
}

/* ─────────────────────────────────────────────────────────────
   Minimap
   ───────────────────────────────────────────────────────────── */

.minimap-panel {
  position: fixed;
  bottom: 80px;
  left: 16px;
  width: 148px;
  height: 104px;
  background: transparent;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  z-index: var(--z-panel);
  box-shadow: var(--shadow-sm);
  cursor: crosshair;
  opacity: 0.38;
  transition: opacity 0.2s ease;
}

.minimap-panel:hover {
  opacity: 0.92;
}

.minimap-panel canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ─────────────────────────────────────────────────────────────
   Sticky Note
   ───────────────────────────────────────────────────────────── */

.sticky-editor {
  position: fixed;
  z-index: 500;
  display: flex;
  flex-direction: column;
  width: 200px;
  min-height: 120px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.sticky-editor__handle {
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: move;
  user-select: none;
  gap: var(--space-1);
}

.sticky-editor__colors {
  display: flex;
  gap: 4px;
  align-items: center;
}

.sticky-editor__color-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  outline: none;
  flex-shrink: 0;
  transition: transform 0.1s, border-color 0.1s;
}

.sticky-editor__color-swatch.active {
  border-color: rgba(0, 0, 0, 0.45);
  transform: scale(1.2);
}

.sticky-editor__color-swatch:hover {
  transform: scale(1.15);
}

.sticky-editor__body {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  font-size: 14px;
  font-family: var(--font-sans);
  border: none;
  background: transparent;
  resize: none;
  outline: none;
  min-height: 96px;
  color: #1A1A2E;
}

/* ─────────────────────────────────────────────────────────────
   Mermaid Modal
   ───────────────────────────────────────────────────────────── */

.mm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.mm-overlay--visible {
  opacity: 1;
  pointer-events: all;
}

.mm-panel {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  width: min(560px, 92vw);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.mm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mm-title {
  font-size: var(--text-lg);
  font-weight: 600;
}

.mm-close {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--color-bg-surface-2);
  border: none; border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
}

.mm-close svg { width: 16px; height: 16px; }
.mm-close:hover { background: var(--color-bg-surface-3); color: var(--color-text-primary); }

.mm-textarea {
  width: 100%;
  min-height: 160px;
  background: var(--color-bg-surface-2);
  border: 1px solid var(--color-border-medium);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  resize: vertical;
  outline: none;
}

.mm-textarea:focus { border-color: var(--color-accent); }

.mm-preview {
  width: 100%;
  min-height: 80px;
  background: var(--color-bg-surface-2);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.mm-preview img {
  max-width: 100%;
  max-height: 200px;
  object-fit: contain;
}

.mm-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}

.mm-btn {
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background var(--transition-fast);
}

.mm-btn--primary {
  background: var(--color-accent);
  color: #fff;
}

.mm-btn--primary:hover { background: var(--color-accent-hover); }

.mm-btn--ghost {
  background: var(--color-bg-surface-2);
  color: var(--color-text-secondary);
}

.mm-btn--ghost:hover { background: var(--color-bg-surface-3); }

/* ─────────────────────────────────────────────────────────────
   User List — follow mode & clickable
   ───────────────────────────────────────────────────────────── */

.ul-avatar:not(.ul-avatar--you) {
  cursor: pointer;
}

.ul-avatar--following .ul-avatar__circle {
  box-shadow: 0 0 0 2px var(--color-accent), 0 0 0 4px var(--color-accent-glow);
  animation: following-pulse 1.5s ease-in-out infinite;
}

@keyframes following-pulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--color-accent), 0 0 0 4px rgba(99,102,241,0.25); }
  50%       { box-shadow: 0 0 0 2px var(--color-accent), 0 0 0 8px rgba(99,102,241,0.1); }
}

/* ─────────────────────────────────────────────────────────────
   Image tool drag-drop highlight
   ───────────────────────────────────────────────────────────── */

.canvas-container.drop-target {
  outline: 3px dashed var(--color-accent);
  outline-offset: -3px;
}

/* ─────────────────────────────────────────────────────────────
   Room Gallery — carrete de fotos
   ───────────────────────────────────────────────────────────── */

.rg-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: var(--z-modal);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.rg-overlay--visible {
  opacity: 1;
  pointer-events: all;
}

.rg-panel {
  width: 100%;
  max-height: 62vh;
  background: var(--color-bg-surface);
  border-top: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  display: flex;
  flex-direction: column;
  padding: var(--space-5) var(--space-6) var(--space-6);
  box-shadow: 0 -8px 40px rgba(0,0,0,0.5);
  transform: translateY(20px);
  transition: transform var(--transition-slow);
}

.rg-overlay--visible .rg-panel {
  transform: translateY(0);
}

.rg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  flex-shrink: 0;
}

.rg-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.rg-header-icon {
  width: 20px;
  height: 20px;
  color: var(--color-accent);
}

.rg-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text-primary);
}

.rg-close {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--color-bg-surface-2);
  border: none; border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
}
.rg-close svg { width: 16px; height: 16px; }
.rg-close:hover { background: var(--color-bg-surface-3); color: var(--color-text-primary); }

/* ── Strip (carrete horizontal) ── */

.rg-strip-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-medium) transparent;
  padding-bottom: var(--space-2);
}

.rg-strip-wrap::-webkit-scrollbar { height: 4px; }
.rg-strip-wrap::-webkit-scrollbar-thumb { background: var(--color-border-medium); border-radius: 2px; }

.rg-strip {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-1) var(--space-1) var(--space-2);
  min-height: 260px;
  align-items: flex-start;
}

/* ── Cards ── */

.rg-card {
  flex-shrink: 0;
  width: 220px;
  background: var(--color-bg-surface-2);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color var(--transition-fast), transform var(--transition-fast), opacity var(--transition-normal);
}

.rg-card:hover {
  border-color: var(--color-border-medium);
  transform: translateY(-2px);
}

.rg-card--current {
  border-color: var(--color-accent);
}

.rg-card--removing {
  opacity: 0;
  transform: scale(0.9);
}

/* Preview area */
.rg-card__preview {
  position: relative;
  width: 100%;
  height: 140px;
  background: #0B0B0F;
  overflow: hidden;
}

.rg-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rg-card__placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
}

.rg-card__placeholder svg { width: 36px; height: 36px; }

.rg-card__badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--color-accent);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

/* Info */
.rg-card__info {
  padding: var(--space-3) var(--space-3) var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rg-card__id {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rg-card__meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* Actions */
.rg-card__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3) var(--space-3);
}

.rg-card__open {
  flex: 1;
  padding: var(--space-2) 0;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast);
}
.rg-card__open:hover { background: var(--color-accent-hover); }
.rg-card__open--current {
  background: var(--color-bg-surface-3);
  color: var(--color-text-secondary);
  cursor: default;
}
.rg-card__open--current:hover { background: var(--color-bg-surface-3); }

.rg-card__delete {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
  flex-shrink: 0;
}
.rg-card__delete svg { width: 14px; height: 14px; }
.rg-card__delete:hover { background: rgba(239,68,68,0.1); color: var(--color-error); border-color: var(--color-error); }

/* ── Empty / loading states ── */

.rg-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  width: 100%;
  min-height: 180px;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  text-align: center;
}
.rg-empty svg { width: 40px; height: 40px; opacity: 0.4; }

.rg-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 180px;
}

.rg-spinner {
  width: 28px; height: 28px;
  color: var(--color-accent);
  animation: rg-spin 1s linear infinite;
}

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

/* ─────────────────────────────────────────────────────────────
   Capture Overlay — region screenshot
   ───────────────────────────────────────────────────────────── */

.co-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  cursor: crosshair;
  display: none;
  user-select: none;
  touch-action: none;
}

.co-overlay--visible {
  display: block;
}

.co-sel-rect {
  position: fixed;
  /* Spotlight effect: huge box-shadow dims everything outside the rect */
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.52);
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 2px;
  pointer-events: none;
  z-index: 2001;
}

.co-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255, 255, 255, 0.92);
  font-size: 15px;
  font-weight: 500;
  text-align: center;
  line-height: 1.5;
  pointer-events: none;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}

.co-hint-sub {
  font-size: 12px;
  opacity: 0.7;
}

.co-actions {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 2002;
}

.co-btn {
  padding: 8px 22px;
  border-radius: var(--radius-lg);
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.95);
  color: #1a1a2e;
  box-shadow: var(--shadow-md);
  transition: background 0.12s;
}

.co-btn:hover {
  background: #fff;
}

.co-btn--cancel {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow: none;
}

.co-btn--cancel:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* ── Capture shutter flash ──────────────────────────────────────────────── */
.co-shutter-flash {
  position: fixed;
  inset: 0;
  background: #fff;
  pointer-events: none;
  z-index: 10001;
  animation: co-shutter 0.42s ease-out forwards;
}

@keyframes co-shutter {
  0%   { opacity: 0.85; }
  25%  { opacity: 0.92; }
  100% { opacity: 0;    }
}
