/* ═══════════════════════════════════════════════════════════════════════════
   Presenting Mode — Free-form Dashboard Overlay / Page
   Power BI / Tableau style drag-anywhere canvas.
   Used both as an overlay inside editor.html (via .is-open toggle)
   and as the full-page layout of dashboard.html (.pm-page modifier).
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Dashboard page host ────────────────────────────────────────────────── */

.pm-page-body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #eef1f7;
  font-family: 'Inter', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── Top navigation bar ─────────────────────────────────────────────────── */

.pm-topnav {
  height: 52px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.1rem;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
  box-shadow: 0 1px 0 rgba(0,0,0,0.04), 0 2px 8px rgba(0,0,0,0.06);
  z-index: 100;
  box-sizing: border-box;
}

.pm-topnav-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.pm-brand-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
  border-radius: 6px;
}

.pm-brand-link:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 3px;
}

.pm-brand-logo {
  width: 150px;
  height: 34px;
  border-radius: 6px;
  object-fit: contain;
}

.pm-brand-meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.83rem;
}

.pm-brand-name {
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.01em;
}

.pm-brand-sep {
  color: #94a3b8;
  font-weight: 400;
}

.pm-brand-page {
  font-weight: 500;
  color: #4f46e5;
}

.pm-topnav-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.pm-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.38rem 0.8rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  line-height: 1;
}

.pm-nav-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.pm-nav-btn--ghost {
  background: #f8fafc;
  border-color: rgba(0, 0, 0, 0.09);
  color: #334155;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.pm-nav-btn--ghost:hover {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #4f46e5;
  box-shadow: 0 1px 6px rgba(79,70,229,0.14);
}

/* ── Body row: sidebar + canvas ─────────────────────────────────────────── */

.pm-body-row {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* ── Left sidebar ───────────────────────────────────────────────────────── */

.pm-sidebar {
  width: var(--layout-sidebar, 220px);
  flex-shrink: 0;
  background: #1e293b;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.12) transparent;
}

.pm-sidebar::-webkit-scrollbar { width: 4px; }
.pm-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
  border-radius: 4px;
}

/* Sidebar brand block */
.pm-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1rem 1rem 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  margin-bottom: 0.35rem;
}

.pm-sidebar-brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #a5b4fc;
}

.pm-sidebar-brand-icon svg {
  width: 16px;
  height: 16px;
}

.pm-sidebar-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.pm-sidebar-brand-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #e2e8f0;
  letter-spacing: -0.01em;
}

.pm-sidebar-brand-sub {
  font-size: 0.68rem;
  font-weight: 500;
  color: #64748b;
  letter-spacing: 0.01em;
}

/* Sidebar section labels */
.pm-sidebar-section-label {
  padding: 0.65rem 1rem 0.3rem;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #475569;
  user-select: none;
}

/* Sidebar action items */
.pm-sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: calc(100% - 1rem);
  margin: 0 0.5rem 0.2rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: #94a3b8;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  line-height: 1;
}

.pm-sidebar-item svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: 0.75;
  transition: opacity 0.15s;
}

.pm-sidebar-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #e2e8f0;
  border-color: rgba(255, 255, 255, 0.08);
}

.pm-sidebar-item:hover svg {
  opacity: 1;
}

.pm-sidebar-item--primary {
  background: rgba(79, 70, 229, 0.18);
  border-color: rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
}

.pm-sidebar-item--primary svg {
  opacity: 0.9;
}

.pm-sidebar-item--primary:hover {
  background: rgba(79, 70, 229, 0.3);
  border-color: rgba(99, 102, 241, 0.5);
  color: #c7d2fe;
}

.pm-sidebar-item--danger {
  color: #fca5a5;
}

.pm-sidebar-item--danger:hover {
  background: rgba(220, 38, 38, 0.15);
  border-color: rgba(220, 38, 38, 0.25);
  color: #fca5a5;
}

.pm-sidebar-spacer {
  flex: 1;
}

/* When the overlay IS the page, make it fill the viewport statically */
.pm-overlay.pm-page {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  opacity: 1 !important;
  visibility: visible !important;
}

/* ── Sidebar Buttons (inside dataset card) ─────────────────────────────── */

.pm-sidebar-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.pm-sidebar-btn {
  margin: 0;
  width: 100%;
  min-height: 24px;
  padding: 0.24rem 0.45rem;
  border-radius: 7px;
  border: 1px solid rgba(148, 163, 184, 0.34);
  background: rgba(148, 163, 184, 0.13);
  color: #e2e8f0;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
}

.pm-sidebar-btn:hover:not(:disabled) {
  transform: none;
  box-shadow: none;
  background: rgba(99, 102, 241, 0.22);
  border-color: rgba(99, 102, 241, 0.46);
  color: #c7d2fe;
}

.pm-sidebar-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.pm-sidebar-btn svg {
  width: 11px;
  height: 11px;
  flex-shrink: 0;
}

.pm-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 999px;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #fff;
  font-size: 0.55rem;
  font-weight: 800;
  line-height: 1;
}

.pm-badge:empty {
  display: none;
}

/* ── Fullscreen Overlay ────────────────────────────────────────────────── */

.pm-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  background: #f1f5f9;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.pm-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

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

.pm-toolbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 1.2rem;
  background: #ffffff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
  flex-shrink: 0;
  z-index: 2;
}

.pm-toolbar-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.01em;
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pm-toolbar-title svg {
  width: 18px;
  height: 18px;
  color: #4f46e5;
}

.pm-toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.09);
  background: #f8fafc;
  color: #334155;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.pm-toolbar-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.7;
}

.pm-toolbar-btn:hover {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #4f46e5;
  box-shadow: 0 1px 6px rgba(79, 70, 229, 0.14);
}

.pm-toolbar-btn:hover svg {
  opacity: 1;
}

.pm-toolbar-btn--primary {
  background: #4f46e5;
  border-color: transparent;
  color: #fff;
  box-shadow: 0 1px 4px rgba(79, 70, 229, 0.3);
}

.pm-toolbar-btn--primary svg {
  opacity: 0.9;
}

.pm-toolbar-btn--primary:hover {
  background: #4338ca;
  color: #fff;
  box-shadow: 0 2px 10px rgba(79, 70, 229, 0.38);
}

.pm-toolbar-btn--danger {
  color: #dc2626;
  border-color: rgba(220, 38, 38, 0.2);
}

.pm-toolbar-btn--danger:hover {
  background: #fef2f2;
  border-color: rgba(220, 38, 38, 0.4);
  color: #b91c1c;
}

.pm-toolbar-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.09);
  background: #f8fafc;
  color: #64748b;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  padding: 0;
  flex-shrink: 0;
}

.pm-toolbar-close svg {
  width: 16px;
  height: 16px;
}

.pm-toolbar-close:hover {
  background: #fee2e2;
  color: #dc2626;
  border-color: rgba(220, 38, 38, 0.3);
}

.pm-toolbar-sep {
  width: 1px;
  height: 22px;
  background: rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

/* ── Canvas (free-form drag area) ──────────────────────────────────────── */

.pm-canvas {
  flex: 1;
  position: relative;
  overflow: auto;
  min-height: 0;
  min-width: 0;
}

.pm-canvas-inner {
  position: relative;
  width: 100%;
  min-height: 100%;
  /* large artboard so users can spread charts out */
  min-width: 1600px;
}

/* ── Empty state ───────────────────────────────────────────────────────── */

.pm-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  pointer-events: none;
  color: #94a3b8;
}

.pm-empty svg {
  width: 48px;
  height: 48px;
  opacity: 0.4;
}

.pm-empty-text {
  font-size: 0.92rem;
  font-weight: 600;
}

.pm-empty-hint {
  font-size: 0.78rem;
  font-weight: 400;
}

/* ── Tile (draggable plot card) ────────────────────────────────────────── */

.pm-tile {
  position: absolute;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.07), 0 4px 16px rgba(15, 23, 42, 0.05);
  overflow: hidden;
  user-select: none;
  transition: box-shadow 0.15s ease;
  cursor: grab;
}

.pm-tile:hover {
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.12), 0 8px 32px rgba(15, 23, 42, 0.08);
}

.pm-tile.is-selected {
  box-shadow: 0 0 0 2px #6366f1, 0 4px 16px rgba(15, 23, 42, 0.12);
  z-index: 20;
}

.pm-tile.is-dragging {
  cursor: grabbing;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.18), 0 0 0 2px rgba(79, 70, 229, 0.3);
  z-index: 100;
  opacity: 0.92;
}

.pm-tile.is-resizing {
  cursor: nwse-resize;
}

/* ── Tile image body (fills full tile) ─────────────────────────────────── */

.pm-tile-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.pm-tile-body img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

/* ── Floating remove button (hidden by default, shown on tile hover) ───── */

.pm-tile-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
  z-index: 10;
  cursor: pointer;
  color: #64748b;
  padding: 0;
}

.pm-tile-remove svg {
  width: 13px;
  height: 13px;
}

/* Reveal remove button and resize handle on tile hover */
.pm-tile:hover .pm-tile-remove {
  opacity: 1;
  pointer-events: auto;
}

.pm-tile-remove:hover {
  background: #fee2e2;
  border-color: rgba(220, 38, 38, 0.3);
  color: #dc2626;
}

/* ── Resize handle (bottom-right corner) ───────────────────────────────── */

.pm-tile-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.pm-tile:hover .pm-tile-resize {
  opacity: 1;
}

.pm-tile-resize::after {
  content: '';
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 8px;
  height: 8px;
  border-right: 2px solid #94a3b8;
  border-bottom: 2px solid #94a3b8;
  border-radius: 0 0 2px 0;
}

/* ── Notification toast ────────────────────────────────────────────────── */

.pm-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 0.5rem 1.1rem;
  border-radius: 10px;
  background: #1e293b;
  color: #e2e8f0;
  font-size: 0.8rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  z-index: 10001;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  white-space: nowrap;
}

.pm-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ═══════════════════════════════════════════════════════════════════════════
   PRINT STYLES — PDF Export via window.print()
   ═══════════════════════════════════════════════════════════════════════════ */

@media print {
  body * {
    visibility: hidden !important;
  }

  .pm-overlay,
  .pm-overlay * {
    visibility: visible !important;
  }

  /* editor: overlay is a fixed layer — lift it to document flow for printing */
  .pm-overlay:not(.pm-page) {
    position: absolute !important;
    inset: 0 !important;
    opacity: 1 !important;
    visibility: visible !important;
    z-index: auto !important;
    background: #fff !important;
  }

  /* dashboard page: already full-page, just override sizes */
  .pm-overlay.pm-page {
    position: relative !important;
    width: 100% !important;
    height: auto !important;
    background: #fff !important;
  }

  .pm-toolbar {
    border-bottom: 2px solid #e2e8f0 !important;
    box-shadow: none !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .pm-toolbar-btn,
  .pm-toolbar-close,
  .pm-toolbar-sep {
    display: none !important;
  }

  .pm-canvas {
    overflow: visible !important;
  }

  .pm-canvas-inner {
    min-width: auto !important;
  }

  .pm-tile {
    box-shadow: none !important;
    border: 1px solid #d1d5db !important;
    break-inside: avoid;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .pm-tile-remove,
  .pm-tile-resize,
  .pm-etoolbar,
  .pm-kb-bar,
  .pm-snap-guides,
  .pm-ctx-menu {
    display: none !important;
  }

  .pm-element.is-selected {
    outline: none !important;
  }

  .pm-toast {
    display: none !important;
  }
}

/* ── Keyboard shortcut hint bar ─────────────────────────────────────────── */

.pm-kb-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 16px;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  z-index: 10;
}

.pm-canvas:hover .pm-kb-bar {
  opacity: 1;
}

.pm-kb-hint {
  font-size: 0.62rem;
  color: rgba(148, 163, 184, 0.9);
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

.pm-kb-sep {
  font-size: 0.6rem;
  color: rgba(100, 116, 139, 0.6);
}

kbd {
  display: inline-block;
  padding: 1px 4px;
  font-size: 0.58rem;
  font-family: inherit;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  color: #e2e8f0;
  line-height: 1.4;
}

/* ── Canvas elements (box, text) ────────────────────────────────────────── */

.pm-element {
  position: absolute;
  user-select: none;
  cursor: grab;
}

.pm-element:hover .pm-tile-remove {
  opacity: 1;
  pointer-events: auto;
}

.pm-element.is-dragging {
  cursor: grabbing;
  z-index: 40;
}

.pm-element.is-resizing {
  cursor: nwse-resize;
}

.pm-element.is-selected {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
  z-index: 30;
}

.pm-element--box {
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
  transition: box-shadow 0.15s;
  overflow: hidden;
}

.pm-element--box:hover {
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
}

.pm-element--text {
  background: transparent;
  overflow: visible;
}

.pm-text-content {
  width: 100%;
  height: 100%;
  padding: 6px 12px;
  box-sizing: border-box;
  word-break: break-word;
  overflow: hidden;
  display: block;
  outline: none;
  line-height: 1.3;
  font-family: 'Inter', 'Plus Jakarta Sans', -apple-system, sans-serif;
  cursor: default;
}

.pm-text-content[contenteditable="true"] {
  overflow: auto;
  cursor: text;
  background: rgba(99, 102, 241, 0.04);
  outline: 2px solid rgba(99, 102, 241, 0.35);
  outline-offset: -2px;
  border-radius: 4px;
}

/* ── Element property toolbar ──────────────────────────────────────────── */

.pm-etoolbar {
  position: absolute;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 4px;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9px;
  padding: 5px 9px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.2);
  min-height: 38px;
  white-space: nowrap;
  pointer-events: auto;
  user-select: none;
}

.pm-etb-label {
  font-size: 0.6rem;
  font-weight: 700;
  color: rgba(148, 163, 184, 0.75);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0 1px;
}

.pm-etb-sep {
  width: 1px;
  height: 22px;
  background: rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
  margin: 0 2px;
}

.pm-etb-val {
  font-size: 0.65rem;
  color: #64748b;
  min-width: 28px;
  text-align: right;
}

/* Color swatch */
.pm-etb-swatch-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.pm-etb-swatch-wrap input[type="color"] {
  position: absolute;
  inset: -8px;
  opacity: 0;
  cursor: pointer;
  width: calc(100% + 16px);
  height: calc(100% + 16px);
  padding: 0;
  border: none;
}

.pm-etb-dot {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  display: block;
  flex-shrink: 0;
  transition: border-color 0.12s;
}

.pm-etb-swatch-wrap:hover .pm-etb-dot {
  border-color: rgba(255, 255, 255, 0.5);
}

/* Range slider */
.pm-etb-range {
  width: 60px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  flex-shrink: 0;
}

.pm-etb-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #6366f1;
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.pm-etb-range::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #6366f1;
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

/* Icon buttons (B, I, align) */
.pm-etb-icon-btn {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  border: 1px solid transparent;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  flex-shrink: 0;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
  padding: 0;
}

.pm-etb-icon-btn:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #e2e8f0;
}

.pm-etb-icon-btn.is-active {
  background: rgba(99, 102, 241, 0.28);
  border-color: rgba(99, 102, 241, 0.5);
  color: #a5b4fc;
}

/* Font size input */
.pm-etb-size {
  width: 44px;
  height: 26px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  color: #e2e8f0;
  font-size: 0.75rem;
  text-align: center;
  padding: 0 4px;
  outline: none;
  flex-shrink: 0;
}

.pm-etb-size:focus {
  border-color: rgba(99, 102, 241, 0.5);
}

/* Delete button */
.pm-etb-delete {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  border: 1px solid rgba(220, 38, 38, 0.3);
  background: rgba(220, 38, 38, 0.1);
  color: #f87171;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s;
  padding: 0;
}

.pm-etb-delete:hover {
  background: rgba(220, 38, 38, 0.25);
  border-color: rgba(220, 38, 38, 0.55);
}

/* ── Background color swatch in sidebar ─────────────────────────────────── */

.pm-sidebar-item--canvasbg {
  justify-content: flex-start;
}

.pm-bg-swatch {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
  margin-left: auto;
  background: #eef1f7;
  display: block;
}

/* ── "Add" sidebar button variant ──────────────────────────────────────── */

.pm-sidebar-item--add {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.28);
  color: #6ee7b7;
}

.pm-sidebar-item--add svg {
  opacity: 0.9;
}

.pm-sidebar-item--add:hover {
  background: rgba(16, 185, 129, 0.24);
  border-color: rgba(16, 185, 129, 0.5);
  color: #a7f3d0;
}

/* ── Add-from-pool picker modal ─────────────────────────────────────────── */

.pm-picker-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
}

.pm-picker {
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.3);
  width: min(640px, 94vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: pm-picker-in 0.2s ease-out;
}

@keyframes pm-picker-in {
  from { opacity: 0; transform: translateY(-12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.pm-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.pm-picker-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
}

.pm-picker-close {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid #e5e7eb;
  background: #f8fafc;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.12s, color 0.12s;
}

.pm-picker-close svg { width: 14px; height: 14px; }

.pm-picker-close:hover {
  background: #fee2e2;
  border-color: rgba(220,38,38,0.3);
  color: #dc2626;
}

.pm-picker-hint {
  margin: 0;
  padding: 0.6rem 1.25rem;
  font-size: 0.78rem;
  color: #64748b;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.pm-picker-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  overflow-y: auto;
}

.pm-picker-card {
  display: flex;
  gap: 0.75rem;
  padding: 0.65rem;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #ffffff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.pm-picker-card:hover {
  border-color: #c7d2fe;
  box-shadow: 0 2px 10px rgba(79,70,229,0.1);
}

.pm-picker-thumb {
  width: 90px;
  height: 64px;
  object-fit: contain;
  border-radius: 6px;
  background: #f1f5f9;
  flex-shrink: 0;
  border: 1px solid #e5e7eb;
}

.pm-picker-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.pm-picker-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pm-picker-meta {
  font-size: 0.7rem;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pm-picker-add-btn {
  margin-top: auto;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  border: 1px solid rgba(79,70,229,0.3);
  background: rgba(79,70,229,0.08);
  color: #4f46e5;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  align-self: flex-start;
  transition: background 0.12s, border-color 0.12s;
}

.pm-picker-add-btn:hover {
  background: rgba(79,70,229,0.18);
  border-color: rgba(79,70,229,0.5);
}

.pm-picker-add-btn--again {
  border-color: rgba(100,116,139,0.3);
  background: rgba(100,116,139,0.08);
  color: #64748b;
}

.pm-picker-add-btn--again:hover {
  background: rgba(100,116,139,0.16);
  border-color: rgba(100,116,139,0.45);
  color: #334155;
}

/* ── Snap alignment guides ──────────────────────────────────────────────── */

.pm-snap-guides {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 200;
  overflow: hidden;
}

.pm-snap-guide {
  position: absolute;
  background: #6366f1;
  opacity: 0.75;
  pointer-events: none;
}

.pm-snap-guide--v {
  top: 0;
  width: 1px;
  height: 100%;
}

.pm-snap-guide--h {
  left: 0;
  height: 1px;
  width: 100%;
}

/* ── Grid sidebar button active state ───────────────────────────────────── */

.pm-sidebar-item--grid-on {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.45);
  color: #a5b4fc;
}

.pm-sidebar-item--grid-on:hover {
  background: rgba(99, 102, 241, 0.28);
  border-color: rgba(99, 102, 241, 0.6);
  color: #c7d2fe;
}

/* ── Right-click context menu ───────────────────────────────────────────── */

.pm-ctx-menu {
  position: fixed;
  z-index: 10002;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 4px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.25);
  min-width: 188px;
  user-select: none;
  animation: ctx-appear 0.1s ease-out;
}

@keyframes ctx-appear {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}

.pm-ctx-group-label {
  padding: 5px 10px 2px;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #475569;
  pointer-events: none;
}

.pm-ctx-sep {
  height: 1px;
  background: rgba(255, 255, 255, 0.07);
  margin: 3px 0;
}

.pm-ctx-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  color: #e2e8f0;
  cursor: pointer;
  gap: 12px;
  transition: background 0.1s;
}

.pm-ctx-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.pm-ctx-item--danger {
  color: #f87171;
}

.pm-ctx-item--danger:hover {
  background: rgba(220, 38, 38, 0.15);
}

.pm-ctx-item--disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

.pm-ctx-shortcut {
  font-size: 0.68rem;
  color: #64748b;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — PC/Laptop compact mode
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 1280px) {
  .pm-toolbar-btn { padding: 0.35rem 0.6rem; font-size: 0.74rem; }
}

@media (max-width: 1024px) {
  .pm-brand-logo { width: 120px; height: 28px; }
  .pm-sidebar-brand-title { font-size: 0.7rem; }
  .pm-toolbar-btn span { display: none; }
  .pm-toolbar-btn { padding: 0.35rem 0.5rem; }
  .pm-nav-btn span { display: none; }
  .pm-nav-btn { padding: 0.35rem 0.5rem; }
}
