/* Freeform board UI theme tokens */
.freeform-library,
.freeform-save-modal,
.freeform-action-modal,
.freeform-autosave-recovery,
.freeform-status-pill,
.delete-confirmation-pill,
.new-board-modal-backdrop {
  --ff-board-surface: rgba(255, 255, 255, 0.98);
  --ff-board-surface-strong: rgba(255, 255, 255, 0.95);
  --ff-board-surface-soft: rgba(0, 0, 0, 0.03);
  --ff-board-surface-softer: rgba(0, 0, 0, 0.02);
  --ff-board-surface-subtle: rgba(0, 0, 0, 0.015);
  --ff-board-hover: rgba(0, 0, 0, 0.06);
  --ff-board-hover-strong: rgba(0, 0, 0, 0.1);
  --ff-board-border: rgba(0, 0, 0, 0.1);
  --ff-board-border-soft: rgba(0, 0, 0, 0.08);
  --ff-board-border-strong: rgba(0, 0, 0, 0.18);
  --ff-board-divider: rgba(0, 0, 0, 0.08);
  --ff-board-text: #222;
  --ff-board-text-strong: #111;
  --ff-board-text-muted: rgba(0, 0, 0, 0.6);
  --ff-board-text-soft: rgba(0, 0, 0, 0.45);
  --ff-board-text-softer: rgba(0, 0, 0, 0.4);
  --ff-board-selection: #222;
  --ff-board-selection-contrast: #fff;
  --ff-board-icon-filter: brightness(0);
  --ff-board-input-bg: rgba(255, 255, 255, 0.9);
  --ff-board-input-focus-bg: #fff;
  --ff-board-input-focus-ring: 0 0 0 3px rgba(0, 0, 0, 0.08);
  --ff-board-shadow: 0 20px 48px rgba(0, 0, 0, 0.2);
  --ff-board-shadow-soft: 0 12px 32px rgba(0, 0, 0, 0.15);
  --ff-board-template-band: rgba(247, 248, 250, 0.92);
  --ff-board-template-shadow: 0 12px 28px rgba(0, 0, 0, 0.035);
  --ff-board-progress-track: rgba(0, 0, 0, 0.1);
  --ff-board-progress-bar: #000;
  --ff-board-spinner-track: rgba(0, 0, 0, 0.1);
  --ff-board-spinner-head: #222;
  --ff-board-success: #16a34a;
  --ff-board-success-border: rgba(22, 163, 74, 0.3);
  --ff-board-danger: #ef4444;
  --ff-board-danger-hover: #dc2626;
}

.freeform-library[data-theme="dark"],
.freeform-save-modal[data-theme="dark"],
.freeform-action-modal[data-theme="dark"],
.freeform-autosave-recovery[data-theme="dark"],
.freeform-status-pill[data-theme="dark"],
.delete-confirmation-pill[data-theme="dark"],
.new-board-modal-backdrop[data-theme="dark"] {
  --ff-board-surface: rgba(18, 20, 26, 0.96);
  --ff-board-surface-strong: rgba(24, 26, 32, 0.96);
  --ff-board-surface-soft: rgba(255, 255, 255, 0.06);
  --ff-board-surface-softer: rgba(255, 255, 255, 0.04);
  --ff-board-surface-subtle: rgba(255, 255, 255, 0.03);
  --ff-board-hover: rgba(255, 255, 255, 0.08);
  --ff-board-hover-strong: rgba(255, 255, 255, 0.14);
  --ff-board-border: rgba(255, 255, 255, 0.14);
  --ff-board-border-soft: rgba(255, 255, 255, 0.1);
  --ff-board-border-strong: rgba(255, 255, 255, 0.24);
  --ff-board-divider: rgba(255, 255, 255, 0.1);
  --ff-board-text: #eef1f7;
  --ff-board-text-strong: #f8fafc;
  --ff-board-text-muted: rgba(238, 241, 247, 0.72);
  --ff-board-text-soft: rgba(238, 241, 247, 0.56);
  --ff-board-text-softer: rgba(238, 241, 247, 0.46);
  --ff-board-selection: #eef1f7;
  --ff-board-selection-contrast: #111317;
  --ff-board-icon-filter: brightness(0) invert(1);
  --ff-board-input-bg: rgba(255, 255, 255, 0.04);
  --ff-board-input-focus-bg: rgba(255, 255, 255, 0.07);
  --ff-board-input-focus-ring: 0 0 0 3px rgba(255, 255, 255, 0.08);
  --ff-board-shadow: 0 24px 56px rgba(0, 0, 0, 0.48);
  --ff-board-shadow-soft: 0 16px 36px rgba(0, 0, 0, 0.36);
  --ff-board-template-band: rgba(255, 255, 255, 0.045);
  --ff-board-template-shadow: 0 14px 30px rgba(0, 0, 0, 0.18);
  --ff-board-progress-track: rgba(255, 255, 255, 0.14);
  --ff-board-progress-bar: #eef1f7;
  --ff-board-spinner-track: rgba(255, 255, 255, 0.18);
  --ff-board-spinner-head: #eef1f7;
  --ff-board-success: #4ade80;
  --ff-board-success-border: rgba(74, 222, 128, 0.28);
  --ff-board-danger: #f87171;
  --ff-board-danger-hover: #ef4444;
  color-scheme: dark;
}

body.freeform-library-open {
  --ff-library-topbar-offset: 0px;
  --ff-library-sidebar-bg: var(--ff-board-surface, rgba(255, 255, 255, 0.98));
  --ff-library-sidebar-surface: rgba(0, 0, 0, 0.035);
  --ff-library-sidebar-surface-strong: rgba(0, 0, 0, 0.06);
  --ff-library-sidebar-hover: rgba(0, 0, 0, 0.055);
  --ff-library-sidebar-border: rgba(0, 0, 0, 0.08);
  --ff-library-sidebar-border-strong: rgba(0, 0, 0, 0.16);
  --ff-library-sidebar-text: #222;
  --ff-library-sidebar-text-strong: #111;
  --ff-library-sidebar-text-muted: rgba(0, 0, 0, 0.55);
  --ff-library-sidebar-text-soft: rgba(0, 0, 0, 0.42);
  --ff-library-sidebar-icon-filter: brightness(0);
  --ff-library-sidebar-shadow: 8px 0 26px rgba(0, 0, 0, 0.045);
}

body.workspace-mode[data-active-module='freeform']:not(.ff-freeform-header-collapsed):not(.mm-module-header-collapsed).freeform-library-open {
  --ff-library-topbar-offset: var(--topbar-height, 60px);
}

@media (max-width: 48em) {
  body.workspace-mode[data-active-module='freeform']:not(.ff-freeform-header-collapsed):not(.mm-module-header-collapsed).freeform-library-open {
    --ff-library-topbar-offset: var(--topbar-height-mobile, 56px);
  }
}

/* Off by default: add .ff-library-sidebar-light to body to let the project sidebar
   share the My Formas Boards day-mode shell while the board browser is open. */
body.freeform-library-open.ff-library-sidebar-light .sidebar {
  background: var(--ff-library-sidebar-bg) !important;
  color: var(--ff-library-sidebar-text) !important;
  border-right-color: var(--ff-library-sidebar-border) !important;
  box-shadow: var(--ff-library-sidebar-shadow) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  transition:
    transform 0.2s ease,
    background 0.22s ease,
    color 0.22s ease,
    border-color 0.22s ease,
    box-shadow 0.22s ease,
    backdrop-filter 0.22s ease !important;
}

body.freeform-library-open.ff-library-sidebar-light .sidebar-header {
  background: var(--ff-library-sidebar-bg) !important;
  border-bottom-color: var(--ff-library-sidebar-border) !important;
}

body.freeform-library-open.ff-library-sidebar-light .sidebar-content,
body.freeform-library-open.ff-library-sidebar-light .sidebar-section,
body.freeform-library-open.ff-library-sidebar-light .sidebar-section#projectsSection {
  background: transparent !important;
}

body.freeform-library-open.ff-library-sidebar-light .sidebar-logo,
body.freeform-library-open.ff-library-sidebar-light .sidebar-item,
body.freeform-library-open.ff-library-sidebar-light .sidebar-item-text,
body.freeform-library-open.ff-library-sidebar-light .project-bucket-header,
body.freeform-library-open.ff-library-sidebar-light .project-bucket-header .bucket-title,
body.freeform-library-open.ff-library-sidebar-light .project-bucket-header .bucket-count,
body.freeform-library-open.ff-library-sidebar-light .folder-header {
  color: var(--ff-library-sidebar-text) !important;
}

body.freeform-library-open.ff-library-sidebar-light .sidebar-logo span:not(.beta-badge):not(.beta-label):not(.beta-version) {
  color: var(--ff-library-sidebar-text-strong) !important;
  -webkit-text-fill-color: var(--ff-library-sidebar-text-strong) !important;
}

body.freeform-library-open.ff-library-sidebar-light .sidebar-section-title,
body.freeform-library-open.ff-library-sidebar-light .project-bucket-header,
body.freeform-library-open.ff-library-sidebar-light .project-bucket-header .bucket-count,
body.freeform-library-open.ff-library-sidebar-light .bucket-chevron,
body.freeform-library-open.ff-library-sidebar-light .folder-arrow {
  color: var(--ff-library-sidebar-text-soft) !important;
}

body.freeform-library-open.ff-library-sidebar-light .project-bucket-header:hover,
body.freeform-library-open.ff-library-sidebar-light .folder-header:hover {
  color: var(--ff-library-sidebar-text-muted) !important;
  background: var(--ff-library-sidebar-hover) !important;
}

body.freeform-library-open.ff-library-sidebar-light .sidebar-logo-triangle polygon {
  animation: none !important;
  fill: var(--ff-library-sidebar-text-strong) !important;
  stroke: var(--ff-library-sidebar-text-strong) !important;
  fill-opacity: 1 !important;
  stroke-opacity: 1 !important;
  opacity: 1 !important;
}

body.freeform-library-open.ff-library-sidebar-light .sidebar-logo .beta-badge,
body.freeform-library-open.ff-library-sidebar-light .sidebar-logo .beta-badge * {
  color: var(--ff-library-sidebar-text-muted) !important;
  -webkit-text-fill-color: var(--ff-library-sidebar-text-muted) !important;
  background: transparent !important;
  border-color: var(--ff-library-sidebar-border-strong) !important;
  box-shadow: none !important;
}

body.freeform-library-open.ff-library-sidebar-light .sidebar-close {
  background: var(--ff-library-sidebar-surface) !important;
  border-color: var(--ff-library-sidebar-border) !important;
  color: var(--ff-library-sidebar-text-muted) !important;
}

body.freeform-library-open.ff-library-sidebar-light .sidebar-close:hover {
  background: var(--ff-library-sidebar-hover) !important;
  border-color: var(--ff-library-sidebar-border-strong) !important;
}

body.freeform-library-open.ff-library-sidebar-light .sidebar-close img,
body.freeform-library-open.ff-library-sidebar-light .sidebar-item-icon img,
body.freeform-library-open.ff-library-sidebar-light .project-shared-badge img {
  filter: var(--ff-library-sidebar-icon-filter) !important;
  opacity: 0.72 !important;
}

body.freeform-library-open.ff-library-sidebar-light .sidebar-item:hover,
body.freeform-library-open.ff-library-sidebar-light .sidebar-item[data-module]:hover,
body.freeform-library-open.ff-library-sidebar-light .sidebar-item.project-item:hover {
  background: var(--ff-library-sidebar-hover) !important;
  color: var(--ff-library-sidebar-text-strong) !important;
  box-shadow: none !important;
}

body.freeform-library-open.ff-library-sidebar-light .sidebar-item .new-badge {
  background: rgba(178, 102, 70, 0.12) !important;
  border-color: rgba(178, 102, 70, 0.28) !important;
  color: #8F4327 !important;
}

body.freeform-library-open.ff-library-sidebar-light .sidebar-item .new-badge.new-badge-free {
  background: rgba(63, 172, 103, 0.14) !important;
  border-color: rgba(63, 172, 103, 0.28) !important;
  color: #2F784B !important;
}

body.freeform-library-open.ff-library-sidebar-light .sidebar-item .coming-soon-badge {
  background: rgba(0, 0, 0, 0.045) !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
  color: rgba(0, 0, 0, 0.5) !important;
}

body.freeform-library-open.ff-library-sidebar-light .sidebar-item.active,
body.freeform-library-open.ff-library-sidebar-light .sidebar-item[data-module].active,
body.freeform-library-open.ff-library-sidebar-light .sidebar-item.project-item.active,
body.freeform-library-open.ff-library-sidebar-light .sidebar-item.project-item.active.active-click-feedback,
body.freeform-library-open.ff-library-sidebar-light .project-bucket-section[data-bucket="most-recent"] .sidebar-item.project-item:first-child {
  background: var(--ff-library-sidebar-surface-strong) !important;
  color: var(--ff-library-sidebar-text-strong) !important;
  box-shadow: inset 0 0 0 1px var(--ff-library-sidebar-border) !important;
}

body.freeform-library-open.ff-library-sidebar-light .sidebar-item[data-module].active::before,
body.freeform-library-open.ff-library-sidebar-light .sidebar-item.project-item.active::before,
body.freeform-library-open.ff-library-sidebar-light .sidebar-item.project-item.active[data-project]::before,
body.freeform-library-open.ff-library-sidebar-light .project-dot-indicator,
body.freeform-library-open.ff-library-sidebar-light .module-dot-indicator {
  background: rgba(0, 0, 0, 0.72) !important;
  box-shadow: none !important;
}

body.freeform-library-open.ff-library-sidebar-light .sidebar-item.active .sidebar-item-icon img,
body.freeform-library-open.ff-library-sidebar-light .sidebar-item:hover .sidebar-item-icon img,
body.freeform-library-open.ff-library-sidebar-light .sidebar-close:hover img {
  opacity: 0.9 !important;
}

body.freeform-library-open.ff-library-sidebar-light .sidebar-item-icon.project-thumb {
  background-color: var(--ff-library-sidebar-surface) !important;
  border-color: var(--ff-library-sidebar-border-strong) !important;
  color: var(--ff-library-sidebar-text-strong) !important;
}

body.freeform-library-open.ff-library-sidebar-light .project-skeleton,
body.freeform-library-open.ff-library-sidebar-light .project-folder {
  background: transparent !important;
}

body.freeform-library-open.ff-library-sidebar-light .project-skeleton-icon,
body.freeform-library-open.ff-library-sidebar-light .project-skeleton-text,
body.freeform-library-open.ff-library-sidebar-light .placeholder-shimmer {
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.035) 0%,
    rgba(0, 0, 0, 0.075) 50%,
    rgba(0, 0, 0, 0.035) 100%
  ) !important;
}

/* Freeform Library Styles */
.freeform-library {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2147483647; /* CRITICAL: Maximum z-index to be ABOVE iconBar in all situations */
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  background: var(--ff-board-surface);
  box-sizing: border-box;
  /* CRITICAL: Allow touch interactions to pass through to modal */
  touch-action: auto;
}

.freeform-library-backdrop {
  display: none;
}

.freeform-library-modal {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  background: var(--ff-board-surface);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin: 0;
  /* CRITICAL: Allow touch interactions inside modal (scroll, tap) */
  touch-action: auto;
}

.freeform-library.mm-library-shell {
  padding: 0;
}

.freeform-library .freeform-library-modal.mm-library-modal {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  border-radius: 0;
}

.library-board-toolbar {
  position: sticky;
  top: 0;
  top: var(--ff-library-topbar-offset, 0px);
  z-index: 5;
  background: var(--ff-board-surface);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.045);
}

body.sidebar-open .freeform-library,
body:has(.sidebar.open) .freeform-library {
  left: var(--sidebar-width, 364px);
}

body.generations-open .freeform-library,
body:has(.main-content.generations-open) .freeform-library {
  right: var(--capsule-panel-width, 360px);
}

@media (max-width: 56.25em) {
  body.sidebar-open .freeform-library,
  body:has(.sidebar.open) .freeform-library,
  body.generations-open .freeform-library,
  body:has(.main-content.generations-open) .freeform-library {
    left: 0;
    right: 0;
  }
}

.library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px clamp(28px, 4vw, 56px) 16px;
  background: var(--ff-board-surface);
  border-bottom: 0;
  flex-shrink: 0;
}

.library-heading {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
}

.library-heading-main {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.library-title {
  color: var(--ff-board-text);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.library-title-icon {
  width: 18px;
  height: 18px;
  display: inline-block;
  filter: var(--ff-board-icon-filter);
  opacity: 0.7;
}

/* Board count (e.g., "39 boards, 3 shared") */
.library-count {
  color: var(--ff-board-text-soft);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.2px;
  flex-shrink: 0;
}

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

.library-count.is-count-pending {
  position: relative;
  display: inline-flex;
  width: 16px;
  height: 16px;
  overflow: hidden;
  color: transparent;
  font-size: 0;
}

.library-count.is-count-pending::after,
.library-tab-count.is-count-pending::after {
  content: '';
  width: 10px;
  height: 10px;
  box-sizing: border-box;
  border: 1.5px solid color-mix(in srgb, currentColor 28%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: library-count-spin 0.75s linear infinite;
}

.library-count.is-count-pending::after {
  position: absolute;
  inset: 3px;
  color: var(--ff-board-text-soft);
}

.library-count.is-count-unavailable,
.library-tab-count.is-count-unavailable {
  color: var(--ff-board-text-soft);
}

.library-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

/* View Mode Toggle */
.library-view-toggle {
  display: flex;
  gap: 2px;
  background: transparent;
  padding: 2px;
  border: 1px solid var(--ff-board-border-soft);
  border-radius: 7px;
  margin-left: 0;
}

.library-view-btn {
  width: 32px;
  height: 30px;
  background: transparent;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  opacity: 0.4;
}

.library-view-btn:hover {
  opacity: 0.7;
  background: var(--ff-board-hover);
}

.library-view-btn.active {
  background: var(--ff-board-surface-soft);
  opacity: 1;
}

.library-view-btn svg {
  width: 16px;
  height: 16px;
  stroke: var(--ff-board-text);
}

/* Search input */
.library-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--ff-board-surface-soft);
  border: 1px solid var(--ff-board-border-soft);
  border-radius: 7px;
  padding: 8px 12px;
  margin-left: 0;
  flex: 1 1 340px;
  max-width: 420px;
  transition: all 0.2s ease;
}

.library-search:focus-within {
  background: var(--ff-board-hover);
  border-color: var(--ff-board-border-strong);
}

.library-search svg {
  width: 14px;
  height: 14px;
  stroke: var(--ff-board-text-soft);
  flex-shrink: 0;
}

.library-search input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 12px;
  font-weight: 500;
  color: var(--ff-board-text);
  width: 100%;
  font-family: system-ui, -apple-system, sans-serif;
}

.library-search input::placeholder {
  color: var(--ff-board-text-soft);
}

.library-close {
  position: static;
  background: transparent;
  border: 1px solid var(--ff-board-border-soft);
  color: var(--ff-board-text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 0;
  border-radius: 7px;
  transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  z-index: 10;
}

@media (hover: hover) {
  .library-close:hover {
    color: var(--ff-board-text);
    background: var(--ff-board-hover-strong);
    border-color: var(--ff-board-border-strong);
  }
}

.library-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 clamp(28px, 4vw, 56px) 12px;
  background: var(--ff-board-surface);
  border-bottom: 1px solid var(--ff-board-divider);
  overflow-x: auto;
  flex-shrink: 0;
}

.library-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--ff-board-text-muted);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
  white-space: nowrap;
}

.library-tab:hover {
  background: var(--ff-board-surface-soft);
  border-color: var(--ff-board-border-soft);
  color: var(--ff-board-text);
}

.library-tab.active {
  background: var(--ff-board-surface-soft);
  border-color: var(--ff-board-border-soft);
  color: var(--ff-board-text);
}

.library-tab svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.library-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--ff-board-surface-soft);
  color: var(--ff-board-text-soft);
  font-size: 11px;
  font-weight: 700;
}

.library-tab-count.is-count-pending {
  padding: 0;
  color: var(--ff-board-text-soft);
}

.library-tab.active .library-tab-count {
  background: var(--ff-board-hover);
  color: currentColor;
}

.library-templates {
  flex-shrink: 0;
  padding: 22px clamp(28px, 4vw, 56px) 20px;
  padding-top: calc(22px + var(--ff-library-topbar-offset, 0px));
  position: relative;
  z-index: 0;
  background: var(--ff-board-template-band);
  border-bottom: 1px solid var(--ff-board-divider);
  box-shadow: var(--ff-board-template-shadow);
}

.library-templates-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  color: var(--ff-board-text);
  font-size: 14px;
  font-weight: 650;
}

.library-sidebar-toggle {
  appearance: none;
  width: 28px;
  flex: 0 0 28px;
  height: 28px;
  border: 1px solid var(--ff-board-border);
  border-radius: 7px;
  background: var(--ff-board-surface);
  color: var(--ff-board-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
  opacity: 1;
  overflow: hidden;
  transform: translateX(0);
  transition:
    width 0.22s ease,
    flex-basis 0.22s ease,
    margin-right 0.22s ease,
    opacity 0.16s ease,
    background 0.14s ease,
    border-color 0.14s ease,
    color 0.14s ease,
    transform 0.22s ease,
    box-shadow 0.14s ease;
}

.library-sidebar-toggle-toolbar {
  margin-right: 0;
}

body.sidebar-open .freeform-library .library-sidebar-toggle {
  width: 0;
  flex-basis: 0;
  margin-right: -10px;
  opacity: 0;
  pointer-events: none;
  border-color: transparent;
  box-shadow: none;
  transform: translateX(-12px);
}

.library-sidebar-toggle svg {
  width: 16px;
  height: 16px;
}

.library-sidebar-toggle:hover {
  background: var(--ff-board-surface-strong);
  border-color: var(--ff-board-border-strong);
  color: var(--ff-board-text-strong);
  transform: translateY(-1px);
}

.library-templates-header small {
  color: var(--ff-board-text-soft);
  font-size: 11px;
  font-weight: 600;
}

.library-template-list {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(180px, 260px);
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.library-template-card {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ff-board-text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  padding: 0;
  text-align: left;
  font-family: system-ui, -apple-system, sans-serif;
}

.library-template-card:disabled,
.library-template-card[aria-disabled="true"] {
  cursor: wait;
  pointer-events: none;
}

.library-templates.template-launch-busy .library-template-card:not(:disabled) {
  pointer-events: none;
}

.library-template-preview {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 10;
  min-height: 0;
  border: 1px solid var(--ff-board-border-soft);
  border-radius: 8px;
  background: #f7f7f6;
  overflow: hidden;
  transition: border-color 0.14s ease, background 0.14s ease, box-shadow 0.14s ease, transform 0.14s ease;
}

.library-template-card:hover .library-template-preview {
  border-color: var(--ff-board-border-strong);
  background: var(--ff-board-surface);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.055);
}

.library-template-card:hover .library-template-title {
  color: var(--ff-board-text-strong);
}

.library-template-preview-light::before,
.library-template-preview-dark::before {
  content: '+';
  color: var(--ff-board-text-soft);
  font-size: 28px;
  font-weight: 300;
  line-height: 1;
}

.library-template-preview-grid {
  background-color: #f7f7f6;
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.045) 1px, transparent 1px),
    linear-gradient(rgba(0, 0, 0, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.07) 1px, transparent 1px);
  background-size: 22px 22px, 22px 22px, 110px 110px, 110px 110px;
}

.library-template-card:hover .library-template-preview-light {
  background-color: #f3f3f2;
}

.library-template-preview-dark {
  background-color: #1d1817;
  background-image:
    linear-gradient(rgba(202, 193, 184, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(202, 193, 184, 0.12) 1px, transparent 1px),
    linear-gradient(rgba(202, 193, 184, 0.2) 1px, transparent 1px),
    linear-gradient(90deg, rgba(202, 193, 184, 0.2) 1px, transparent 1px);
  border-color: rgba(202, 193, 184, 0.24);
}

.library-template-card:hover .library-template-preview-dark {
  background-color: #211c1b;
  border: 1px solid rgba(202, 193, 184, 0.34) !important;
}

.library-template-preview-dark::before {
  color: rgba(202, 193, 184, 0.82);
}

.library-template-preview-tutorial {
  align-items: stretch;
  justify-content: center;
}

.library-template-preview-tutorial img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.library-template-title {
  color: var(--ff-board-text);
  font-size: 12px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-template-subtitle {
  color: var(--ff-board-text-soft);
  font-size: 11px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-scroll-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 0;
  /* CRITICAL: Enable touch scrolling on iOS/iPadOS */
  touch-action: pan-y;
  -ms-touch-action: pan-y;
  /* Ensure scroll works even when touch events are captured elsewhere */
  overscroll-behavior: contain;
}

/* Unconditional pan-y across the modal subtree. Beats `.module-root *`
   (0,1,0) via descendant-selector specificity (0,1,1), without
   !important and without widening beyond the modal. Applies on macOS
   trackpad gestures (which bypass the touch-only media query) as well
   as on real touch devices. */
.freeform-library-modal,
.freeform-library-modal * {
  touch-action: pan-y;
}

/* Templates strip scrolls horizontally on touch. The blanket pan-y above
   is intersected down the ancestor chain, so pan-x must be re-granted on
   the strip, the cards inside it, AND every ancestor up to the scroll
   container — otherwise a swipe started on a card freezes (only the grid
   gaps would scroll). pan-x pan-y keeps vertical library scroll and card
   taps working. */
.freeform-library .library-scroll-container,
.freeform-library .library-templates,
.freeform-library .library-template-list,
.freeform-library .library-template-list * {
  touch-action: pan-x pan-y;
}

.freeform-library .library-template-list {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

/* Beat the shared mobile `!important` pan-y on the scroll container
   (libraryModalMobile.css). Scoped to .freeform-library so other
   mm-library-shell modals stay untouched. */
@media (hover: none) and (pointer: coarse) {
  .freeform-library.mm-library-shell .library-scroll-container {
    touch-action: pan-x pan-y !important;
  }
}

/* Thumbnail Grid View */
.library-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  padding: 22px clamp(28px, 4vw, 56px) 40px;
}

.library-list.list-view {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.library-load-more-button {
  grid-column: 1 / -1;
  align-self: center;
  justify-self: center;
  min-height: 38px;
  margin: 10px auto 0;
  padding: 8px 16px;
  border: 1px solid var(--ff-board-border-strong);
  border-radius: 999px;
  background: var(--ff-board-surface-strong);
  color: var(--ff-board-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.library-load-more-button:hover:not(:disabled) {
  background: var(--ff-board-hover);
}

.library-load-more-button:focus-visible {
  outline: 2px solid var(--ff-board-selection);
  outline-offset: 2px;
}

.library-load-more-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.library-empty {
  margin: 22px clamp(28px, 4vw, 56px) 40px;
}

.library-item {
  background: var(--ff-board-surface-soft);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
  border: 1px solid var(--ff-board-border-soft);
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  transform: translateZ(0);
}

/* Hover effects gated so they don't stick on iOS after tap */
@media (hover: hover) {
  .library-item:hover {
    background: var(--ff-board-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.08);
    border-color: var(--ff-board-border-strong);
  }
}

.library-item.active {
  border-color: var(--ff-board-selection);
  box-shadow: 0 0 0 1px var(--ff-board-selection), 0 6px 16px rgba(0,0,0,0.08);
}

.library-item.board-delete-exit {
  pointer-events: none;
  opacity: 0;
  transform: scale(0.985);
  filter: saturate(0.75);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease,
    filter 0.18s ease;
}

.library-item.active::after {
  content: '✓';
  position: absolute;
  top: 10px;
  left: 10px;
  width: 24px;
  height: 24px;
  background: var(--ff-board-selection);
  color: var(--ff-board-selection-contrast);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  z-index: 10;
  animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* When an item is loading, dim all OTHER items */
.library-list:has(.library-item.loading) .library-item:not(.loading) {
  opacity: 0.3;
  pointer-events: none;
  filter: grayscale(0.5);
  transition: all 0.3s ease;
}

/* The loading item gets highlighted */
.library-item.loading {
  pointer-events: none;
  border-color: var(--ff-board-selection) !important;
  box-shadow: 
    0 0 0 2px var(--ff-board-border),
    0 8px 24px rgba(0, 0, 0, 0.15) !important;
  transform: scale(1.02);
  z-index: 10;
  filter: none !important;
}

/* Ensure thumbnail image stays clear */
.library-item.loading .item-preview img {
  filter: none !important;
  opacity: 1 !important;
}

@keyframes freeform-spin { 
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); } 
}

.item-preview {
  aspect-ratio: 16/10;
  min-height: 0;
  background: var(--ff-board-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

/* Smooth Hover Gradient Overlay */
.item-preview::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.05) 0%, rgba(0,0,0,0) 30%, rgba(0,0,0,0) 70%, rgba(0,0,0,0.1) 100%);
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 2;
  pointer-events: none;
}

.library-item:not(.loading):hover .item-preview::before {
  opacity: 1;
}

.item-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.library-item:hover .item-preview img {
  transform: scale(1.03);
}

.board-live-presence {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  max-width: calc(100% - 16px);
  pointer-events: auto;
  filter: drop-shadow(0 6px 14px rgba(15, 23, 42, 0.24));
}

.board-live-presence::after {
  content: '';
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #22c55e;
  border: 2px solid var(--ff-board-surface);
  z-index: 2;
}

.board-live-avatar,
.board-live-overflow {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 2px solid var(--ff-board-surface);
  background: var(--board-presence-color, #64748b);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  overflow: hidden;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.18);
}

.board-live-avatar + .board-live-avatar,
.board-live-avatar + .board-live-overflow,
.board-live-overflow + .board-live-avatar {
  margin-left: -7px;
}

.board-live-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: none !important;
  opacity: 1 !important;
  transition: none;
}

.board-live-overflow {
  background: #111827;
  font-size: 8px;
}

.preview-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, var(--ff-board-surface-soft) 0%, var(--ff-board-hover) 100%);
  color: var(--ff-board-text-softer);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-family: system-ui, -apple-system, sans-serif;
}

.item-info {
  padding: 12px 14px 13px;
  background: transparent;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.library-item:hover .item-info {
  background: var(--ff-board-surface-softer);
}

.item-date {
  color: var(--ff-board-text-softer);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2px;
  margin-top: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.library-item:hover .item-date {
  color: var(--ff-board-text-muted);
}

.item-name {
  color: var(--ff-board-text);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.2px;
  position: relative;
  transition: all 0.3s ease;
  line-height: 1.3;
}

.item-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.item-name-row .item-name {
  flex: 1 1 auto;
}

.item-badge-row {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex: 0 0 auto;
}

.item-meta-line {
  color: var(--ff-board-text-softer);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.library-item:hover .item-name {
  color: var(--ff-board-text-strong);
}

/* Shared badge - MONOCHROME */
.item-shared-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-left: 0;
  min-width: 38px;
  height: 26px;
  padding: 0 8px;
  background: var(--ff-board-surface-soft);
  border: 1px solid var(--ff-board-border);
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ff-board-text-muted);
  letter-spacing: 0;
  vertical-align: middle;
}

.item-access-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 26px;
  padding: 0 9px;
  border-radius: 8px;
  border: 1px solid var(--ff-board-border);
  background: var(--ff-board-surface-soft);
  color: var(--ff-board-text-muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0;
  white-space: nowrap;
  vertical-align: middle;
}

.item-access-badge-editing {
  border-color: rgba(122, 140, 122, 0.34);
}

.item-access-badge-commenting {
  border-color: rgba(110, 138, 150, 0.34);
}

.freeform-library[data-theme="dark"] .item-access-badge-editing {
  border-color: rgba(157, 178, 157, 0.28);
}

.freeform-library[data-theme="dark"] .item-access-badge-commenting {
  border-color: rgba(135, 172, 188, 0.28);
}

.item-shared-badge-icon {
  width: 14px;
  height: 14px;
  display: block;
  flex-shrink: 0;
  object-fit: contain;
  filter: brightness(0);
  opacity: 0.54;
}

.freeform-library[data-theme="dark"] .item-shared-badge-icon {
  filter: brightness(0) invert(1);
  opacity: 0.72;
}

.item-realtime-legacy-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  min-width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid rgba(194, 143, 42, 0.42);
  background: rgba(194, 143, 42, 0.10);
  color: #9b6e18;
  box-shadow: none;
  pointer-events: auto;
  vertical-align: middle;
  flex: 0 0 auto;
}

.item-realtime-legacy-badge img {
  width: 15px;
  height: 15px;
  display: block;
  flex-shrink: 0;
  object-fit: contain;
}

.item-realtime-legacy-badge::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 0;
  bottom: calc(100% + 6px);
  z-index: 40;
  transform: translateY(3px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  background: #b8821a;
  color: #fff8e8;
  box-shadow: 0 8px 18px rgba(104, 72, 15, 0.22);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0;
  line-height: 1;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.item-realtime-legacy-badge:hover::after,
.item-realtime-legacy-badge:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.item-realtime-legacy-badge:focus-visible {
  outline: 2px solid rgba(184, 130, 26, 0.34);
  outline-offset: 2px;
}

.library-list.list-view .item-realtime-legacy-badge {
  width: 22px;
  min-width: 22px;
  height: 22px;
  border-radius: 7px;
}

.library-list.list-view .item-realtime-legacy-badge img {
  width: 13px;
  height: 13px;
}

.freeform-library[data-theme="dark"] .item-realtime-legacy-badge {
  background: rgba(216, 167, 72, 0.15);
  border-color: rgba(216, 167, 72, 0.42);
  color: #e1b85e;
}

.freeform-library[data-theme="dark"] .item-realtime-legacy-badge::after {
  background: #d6a646;
  color: #231908;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.36);
}

/* legacy placeholder kept for old cached DOM; new badges are footer-only */
.item-preview > .item-realtime-legacy-badge {
  display: none;
}

/* Tooltip for rename */
.item-name[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 0;
  background: var(--ff-board-selection);
  color: var(--ff-board-selection-contrast);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  animation: tooltipFadeIn 0.2s ease forwards;
  animation-delay: 0.5s;
  z-index: 100;
  font-weight: 500;
  letter-spacing: 0.2px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

@keyframes tooltipFadeIn {
  to { opacity: 1; transform: translateY(0); }
}

.item-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  opacity: 1;
  transition: opacity 0.2s;
  z-index: 5;
  display: flex;
  gap: 6px;
}

.library-item:hover .item-actions {
  opacity: 1;
}

.action-btn {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.11);
  color: rgba(20, 22, 26, 0.78);
  min-width: 28px;
  width: 28px;
  height: 28px;
  padding: 0;
  flex-shrink: 0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.2s;
  box-sizing: border-box;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.freeform-library[data-theme="dark"] .action-btn {
  background: rgba(12, 14, 18, 0.76);
  border-color: rgba(255, 255, 255, 0.16);
  color: rgba(248, 250, 252, 0.86);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.38);
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(0, 0, 0, 0.2);
  color: #111317;
}

.freeform-library[data-theme="dark"] .action-btn:hover {
  background: rgba(18, 20, 26, 0.92);
  border-color: rgba(255, 255, 255, 0.26);
  color: #ffffff;
}

.library-item.star-removing {
  opacity: 0;
  transform: scale(0.985);
  transition: opacity 0.12s ease, transform 0.12s ease;
  pointer-events: none;
}

.star-btn.active {
  color: #111317;
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(0, 0, 0, 0.22);
}

.freeform-library[data-theme="dark"] .star-btn.active {
  color: #ffffff;
  background: rgba(18, 20, 26, 0.94);
  border-color: rgba(255, 255, 255, 0.28);
}

/* Ensure SVG icon */
.action-btn svg {
  width: 14px !important;
  height: 14px !important;
  stroke: currentColor !important;
  stroke-width: 2.5px !important;
  opacity: 1 !important;
  display: block;
}

.action-btn:hover svg {
  opacity: 1;
}

.action-btn.delete-btn:hover {
  background: #ef4444;
  border-color: #ef4444;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}

.action-btn.delete-btn:hover svg {
  stroke: white !important;
}

.library-empty {
  text-align: center;
  color: var(--ff-board-text-softer);
  padding: 48px 24px;
  font-size: 13px;
  letter-spacing: 0.2px;
}

/* =====================================================
   LIST VIEW STYLES
   ===================================================== */
/* Hide autosave badge inside preview in list view */
.library-list.list-view .autosave-badge {
  display: none;
}

/* Show autosave indicator as text next to name in list view */
.library-list.list-view .item-autosave-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding: 2px 6px;
  background: var(--ff-board-surface-soft);
  border-radius: 4px;
  font-size: 8px;
  font-weight: 700;
  color: var(--ff-board-text-soft);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* In grid view, hide the text label */
.library-list:not(.list-view) .item-autosave-label {
  display: none;
}

/* Loading overlay in list view - smaller spinner, centered, no text */
.library-list.list-view .freeform-load-overlay {
  background: var(--ff-board-surface-strong) !important;
}

.library-list.list-view .freeform-load-pill {
  flex-direction: row !important;
  gap: 0 !important;
}

.library-list.list-view .freeform-load-spinner {
  width: 20px !important;
  height: 20px !important;
  border-width: 2px !important;
}

.library-list.list-view .freeform-load-text {
  display: none !important;
}

.library-list.list-view .library-item:hover .item-actions {
  opacity: 1;
}

.library-list.list-view .library-item:hover {
  transform: none;
  box-shadow: none;
}

.library-list.list-view .library-item.active::after {
  display: none;
}

.library-list.list-view .item-actions {
  position: static;
  opacity: 1;
  width: 112px;
  justify-content: flex-end;
  gap: 6px;
  transition: none;
}

.library-list.list-view .action-btn {
  width: 28px;
  min-width: 28px;
  height: 28px;
  border-color: transparent;
  background: transparent;
  color: var(--ff-board-text-muted);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.library-list.list-view .action-btn:hover {
  background: var(--ff-board-surface-soft);
  border-color: var(--ff-board-border-soft);
  transform: none;
}

.library-list.list-view .action-btn svg {
  width: 13px !important;
  height: 13px !important;
  stroke: currentColor !important;
  stroke-width: 2.35px !important;
  opacity: 1 !important;
}

.library-list.list-view .versions-btn {
  background: transparent;
  color: var(--ff-board-text-soft);
}

.library-list.list-view .versions-btn:hover {
  background: var(--ff-board-selection);
  border-color: var(--ff-board-selection);
  color: var(--ff-board-selection-contrast);
  transform: none;
}

.library-list.list-view .delete-btn:hover {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.16);
  color: var(--ff-board-danger);
  transform: none;
}

/* ========================================
   LIST VIEW HEADER & COLUMN ALIGNMENT
   Using CSS Grid for perfect alignment
   ======================================== */

/* Header row - sticky with no gap */
.library-list-header {
  display: grid;
  grid-template-columns: 64px minmax(220px, 1.4fr) minmax(130px, 0.8fr) 110px minmax(120px, 0.7fr) 120px;
  align-items: center;
  padding: 9px 0;
  gap: 16px;
  border-bottom: 1px solid var(--ff-board-divider);
  margin: -10px 0 0;
  position: sticky;
  top: -22px;
  background: var(--ff-board-surface);
  z-index: 5;
}

/* Header column containers */
.header-col-preview { /* grid handles width */ }
.header-col-name { min-width: 0; }
.header-col-people { }
.header-col-modified { }
.header-col-owner { }
.header-col-actions { }

.header-cell {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ff-board-text-softer);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: system-ui, -apple-system, sans-serif;
}

.header-cell:hover {
  background: var(--ff-board-surface-soft);
  color: var(--ff-board-text-muted);
}

.header-cell.active {
  background: var(--ff-board-surface-soft);
  border-color: var(--ff-board-border-soft);
  color: var(--ff-board-text);
}

.header-label {
  white-space: nowrap;
}

.header-arrow-icon {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  opacity: 0.9;
}

/* List items use same grid as header */
.library-list.list-view .library-item {
  display: grid;
  grid-template-columns: 64px minmax(220px, 1.4fr) minmax(130px, 0.8fr) 110px minmax(120px, 0.7fr) 120px;
  align-items: center;
  min-height: 68px;
  padding: 10px 0;
  margin-left: 0;
  margin-right: 0;
  border: none;
  border-bottom: 1px solid var(--ff-board-divider);
  border-radius: 0;
  background: transparent;
  gap: 16px;
  transform: none;
  transition: background 0.12s ease, border-color 0.12s ease;
  contain: layout paint;
}

.library-list.list-view .library-item:hover {
  background: var(--ff-board-surface-subtle);
  border-color: var(--ff-board-divider);
}

.library-list.list-view .library-item.active {
  background: var(--ff-board-surface-soft);
  border-color: var(--ff-board-divider);
  box-shadow: none;
}

.library-list.list-view .item-preview {
  width: 56px;
  height: 42px;
  aspect-ratio: auto;
  flex-shrink: 0;
  border-radius: 6px;
  border: 1px solid var(--ff-board-border-soft);
  background: var(--ff-board-surface-soft);
}

.library-list.list-view .item-preview::before {
  display: none;
}

.library-list.list-view .item-preview img {
  transform: none !important;
  transition: opacity 0.18s ease;
  will-change: auto;
}

.library-list.list-view .board-live-presence {
  right: 3px;
  bottom: 3px;
  max-width: 50px;
  filter: drop-shadow(0 3px 8px rgba(15, 23, 42, 0.2));
}

.library-list.list-view .board-live-presence::after {
  right: -1px;
  bottom: -1px;
  width: 6px;
  height: 6px;
  border-width: 1.5px;
}

.library-list.list-view .board-live-avatar,
.library-list.list-view .board-live-overflow {
  width: 16px;
  height: 16px;
  border-width: 1.5px;
  font-size: 7px;
}

.library-list.list-view .board-live-avatar + .board-live-avatar,
.library-list.list-view .board-live-avatar + .board-live-overflow,
.library-list.list-view .board-live-overflow + .board-live-avatar {
  margin-left: -5px;
}

.library-list.list-view .library-item:hover .item-preview img {
  transform: none;
}

.library-list.list-view .item-info {
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: transparent !important;
  min-width: 0;
  overflow: hidden;
}

.library-list.list-view .item-name {
  min-width: 0;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Column layout for meta info in list view */
.library-list.list-view .item-meta {
  display: none; /* Hide old meta, using columns instead */
}

/* Item columns - grid handles widths */
.library-list.list-view .item-col-people,
.library-list.list-view .item-col-owner {
  color: var(--ff-board-text-muted);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.library-list.list-view .item-col-modified {
  color: var(--ff-board-text-muted);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.library-list.list-view .item-col-people {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

/* People info column in list view - MONOCHROME */
.library-list.list-view .item-people-info,
.library-list.list-view .item-private-info {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0;
  color: var(--ff-board-text-muted);
  font-size: 10px;
  font-weight: 600;
  flex-shrink: 0;
  max-width: 100%;
}

.library-list.list-view .item-access-badge {
  height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ff-board-text-muted);
  font-size: 11px;
  font-weight: 650;
}

.library-list.list-view .item-access-badge::after {
  content: "·";
  margin-left: 5px;
  color: var(--ff-board-text-softer);
  font-weight: 600;
}

.library-list.list-view .item-people-info svg {
  width: 12px;
  height: 12px;
  stroke: var(--ff-board-text-soft);
  flex-shrink: 0;
}

.library-list.list-view .item-people-icon {
  width: 14px;
  height: 14px;
  display: block;
  flex-shrink: 0;
  object-fit: contain;
  filter: brightness(0);
  opacity: 0.54;
}

.freeform-library[data-theme="dark"] .library-list.list-view .item-people-icon {
  filter: brightness(0) invert(1);
  opacity: 0.72;
}

.library-list.list-view .item-people-count span {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

.library-list.list-view .item-people-info span {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Empty people column just takes up space */
.library-list.list-view .item-col-people:empty {
  min-width: 90px;
}

/* Backups section (separate from primary boards list) */
.library-backups-section {
  grid-column: 1 / -1;
  border: 1px dashed var(--ff-board-border-strong);
  border-radius: 12px;
  background: var(--ff-board-surface-subtle);
  overflow: hidden;
  margin-top: 2px;
}

.library-backups-toggle {
  width: 100%;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  cursor: pointer;
}

.library-backups-toggle:hover {
  background: var(--ff-board-surface-soft);
}

.library-backups-heading {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.library-backups-title {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.7px;
  color: var(--ff-board-text-muted);
}

.library-backups-subtitle {
  font-size: 10px;
  color: var(--ff-board-text-soft);
  letter-spacing: 0.2px;
}

.library-backups-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.library-backups-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  border-radius: 999px;
  background: var(--ff-board-surface-soft);
  color: var(--ff-board-text-muted);
  font-size: 10px;
  font-weight: 700;
}

.library-backups-chevron {
  color: var(--ff-board-text-softer);
  font-size: 12px;
  transition: transform 0.18s ease;
}

.library-backups-section.expanded .library-backups-chevron {
  transform: rotate(180deg);
}

.library-backups-content {
  display: none;
  gap: 12px;
  padding: 10px;
}

.library-backups-section.expanded .library-backups-content {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.library-backups-section.list-view .library-backups-content {
  padding: 8px 10px 10px;
}

.library-backups-section.list-view.expanded .library-backups-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.library-backups-content .library-item {
  margin: 0;
}

/* --- Phase 3: iPad portrait / small-tablet breakpoint -------------
   iPad Mini (744px) and iPad Pro 11" (834px) portrait are both above
   the 700px mobile breakpoint, so they ran the full desktop layout.
   Compress header padding and drop the thumbnail grid 4 → 3 cols so
   cards don't squish. Desktop (>900px) remains untouched.
   --------------------------------------------------------------- */
@media (min-width: 43.75em) and (max-width: 56.25em) {
  .library-header {
    padding: 18px 20px 14px;
  }

  .library-search {
    max-width: 180px;
  }

  .library-count {
    margin-right: 44px;
  }

  .library-list {
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
  }
}

/* Mobile / tablet / touch responsive rules now live in the shared
   partial: static/js/mm/modules/_shared/styles/libraryModalMobile.css
   The freeform modal opts in via the .mm-library-shell + .mm-library-modal
   marker classes on its template (freeform/ui/templates.js).
   Freeform-only mobile rule kept below: backups grid. */

@media (max-width: 43.75em) {
  .freeform-library.mm-library-shell {
    padding: 0;
  }

  .freeform-library .freeform-library-modal.mm-library-modal {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }

  .freeform-library .library-header {
    padding: 14px 16px 12px;
    align-items: flex-start;
  }

  .freeform-library .library-heading {
    flex: 1 1 100%;
  }

  .freeform-library .library-toolbar {
    flex: 1 1 100%;
    width: 100%;
  }

  .freeform-library .library-view-toggle {
    margin-right: 0;
  }

  .freeform-library .library-nav {
    padding: 0 16px 12px;
  }

  .freeform-library .library-scroll-container {
    padding: 0;
  }

  .freeform-library .library-templates {
    padding: calc(16px + var(--ff-library-topbar-offset, 0px)) 16px 16px;
  }

  .freeform-library .library-list {
    padding: 14px 16px 24px;
  }

  .freeform-library .library-list.list-view .item-col-people,
  .freeform-library .library-list.list-view .item-col-owner {
    display: none;
  }

  .library-backups-section.expanded .library-backups-content {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Skeleton Loading */
.library-item-skeleton {
  background: transparent;
  border-radius: 8px;
  overflow: hidden;
  height: auto;
  min-height: 0;
  border: 1px solid var(--ff-board-border-soft);
  width: 100%;
  display: flex;
  flex-direction: column;
}

.library-list-refresh-card {
  pointer-events: none;
  background: var(--ff-board-surface);
  border-color: var(--ff-board-border-strong);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.055);
  opacity: 0;
  animation: boardListRefreshSkeletonEnter 160ms ease-out forwards;
  animation-delay: calc(var(--board-list-refresh-index, 0) * 24ms);
}

.library-list-refresh-card .skeleton-preview {
  background: linear-gradient(90deg,
    var(--ff-board-surface-soft),
    var(--ff-board-hover-strong),
    var(--ff-board-surface-soft));
  background-size: 240% 100%;
}

@keyframes boardListRefreshSkeletonEnter {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.skeleton-preview {
  height: auto;
  aspect-ratio: 16 / 10;
  flex: 0 0 auto;
  background: linear-gradient(90deg, var(--ff-board-surface-soft), var(--ff-board-hover), var(--ff-board-surface-soft));
  background-size: 240% 100%;
  animation: skeletonSweep 1.4s infinite ease;
}

.skeleton-info {
  padding: 14px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.library-item-skeleton:not(.list-skeleton) .skeleton-info {
  min-height: 62px;
}

.library-item-skeleton .skeleton-line {
  height: 10px;
  background: linear-gradient(90deg, var(--ff-board-surface-soft), var(--ff-board-hover), var(--ff-board-surface-soft));
  background-size: 240% 100%;
  border-radius: 4px;
  animation: skeletonSweep 1.4s infinite ease;
}

@keyframes skeletonSweep {
  0% { background-position: 140% 0; }
  100% { background-position: -100% 0; }
}

.library-list.list-view.loading-skeleton {
  gap: 0;
}

.library-list.list-view .library-item-skeleton.list-skeleton {
  display: grid;
  grid-template-columns: 64px minmax(220px, 1.4fr) minmax(130px, 0.8fr) 110px minmax(120px, 0.7fr) 104px;
  align-items: center;
  gap: 16px;
  height: 68px;
  border: none;
  border-bottom: 1px solid var(--ff-board-divider);
  border-radius: 0;
}

.library-list.list-view .library-item-skeleton.list-skeleton .skeleton-preview {
  width: 56px;
  height: 42px;
  border-radius: 6px;
}

.library-list.list-view .library-item-skeleton.list-skeleton .skeleton-info {
  padding: 0;
  gap: 8px;
  min-width: 0;
}

.library-list.list-view .library-item-skeleton.list-skeleton .skeleton-title {
  width: min(220px, 72%);
  height: 12px;
}

.library-list.list-view .library-item-skeleton.list-skeleton .skeleton-meta {
  width: min(150px, 54%);
  height: 9px;
}

.library-list.list-view .library-item-skeleton.list-skeleton .skeleton-people,
.library-list.list-view .library-item-skeleton.list-skeleton .skeleton-owner {
  width: 82px;
  height: 10px;
}

.library-list.list-view .library-item-skeleton.list-skeleton .skeleton-date {
  width: 54px;
  height: 10px;
}

.library-list.list-view .library-item-skeleton.list-skeleton .skeleton-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.library-list.list-view .library-item-skeleton.list-skeleton .skeleton-actions span {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--ff-board-surface-soft), var(--ff-board-hover), var(--ff-board-surface-soft));
  background-size: 240% 100%;
  animation: skeletonSweep 1.4s infinite ease;
}

/* Save panel (explicit Save / Save as copy / Overwrite) */
.freeform-save-modal {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.freeform-save-modal.visible {
  opacity: 1;
}

.freeform-save-panel {
  width: min(560px, calc(100vw - 40px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--ff-board-surface);
  border: 1px solid var(--ff-board-border);
  border-radius: 18px;
  box-shadow: var(--ff-board-shadow);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transform: translateY(6px) scale(0.98);
  transition: transform 0.2s cubic-bezier(0.2, 0.9, 0.2, 1);
}

.freeform-save-modal.visible .freeform-save-panel {
  transform: translateY(0) scale(1);
}

.freeform-save-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.freeform-save-title {
  margin: 0;
  font-size: 19px;
  color: var(--ff-board-text-strong);
  letter-spacing: 0.1px;
}

.freeform-save-subtitle {
  margin: 0;
  color: var(--ff-board-text-muted);
  font-size: 13px;
}

.freeform-save-context-card {
  border: 1px solid var(--ff-board-border-soft);
  border-radius: 12px;
  background: var(--ff-board-surface-softer);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.freeform-save-context-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.freeform-save-context-label {
  color: var(--ff-board-text-soft);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.55px;
  font-weight: 700;
}

.freeform-save-context-value {
  color: var(--ff-board-text-strong);
  font-size: 12px;
  font-weight: 600;
  text-align: right;
}

.freeform-save-context-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--ff-board-surface-soft);
  color: var(--ff-board-text-muted);
  font-size: 10px;
  letter-spacing: 0.45px;
  font-weight: 700;
}

.freeform-save-field-label {
  color: var(--ff-board-text-soft);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.55px;
  font-weight: 700;
}

.freeform-save-input,
.freeform-save-select {
  width: 100%;
  border: 1px solid var(--ff-board-border-strong);
  border-radius: 11px;
  background: var(--ff-board-input-bg);
  color: var(--ff-board-text-strong);
  padding: 12px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.freeform-save-input:focus,
.freeform-save-select:focus {
  border-color: var(--ff-board-selection);
  box-shadow: var(--ff-board-input-focus-ring);
  background: var(--ff-board-input-focus-bg);
}

.freeform-save-input::placeholder {
  color: var(--ff-board-text-soft);
}

.freeform-save-input.error {
  border-color: #dc2626;
}

.freeform-save-modes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.freeform-save-mode-btn {
  border: 1px solid var(--ff-board-border);
  border-radius: 11px;
  background: var(--ff-board-surface-softer);
  padding: 10px 10px 11px;
  text-align: left;
  cursor: pointer;
  transition: all 0.18s ease;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.freeform-save-mode-btn:hover {
  background: var(--ff-board-surface-soft);
}

.freeform-save-mode-btn.active {
  border-color: var(--ff-board-selection);
  background: var(--ff-board-hover);
}

.freeform-save-mode-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.freeform-save-mode-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--ff-board-text-strong);
}

.freeform-save-mode-desc {
  font-size: 10px;
  color: var(--ff-board-text-soft);
}

.freeform-save-overwrite-target {
  display: none;
}

.freeform-save-overwrite-target.visible {
  display: block;
}

.freeform-save-realtime-option {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--ff-board-border-soft);
  border-radius: 12px;
  background: var(--ff-board-surface-softer);
  padding: 11px 12px;
  /* Smooth fade between the neutral "off" surface and the warm earthy
     "on" surface so toggling the switch feels intentional, not abrupt. */
  transition:
    background 380ms cubic-bezier(0.32, 0.72, 0, 1),
    border-color 380ms cubic-bezier(0.32, 0.72, 0, 1),
    box-shadow 380ms cubic-bezier(0.32, 0.72, 0, 1);
}

.freeform-save-realtime-option.visible {
  display: flex;
}

/* Active state — slightly desaturated amber gradient that reads as
   formas-earthy without competing with the toggle's brighter amber. */
.freeform-save-realtime-option.active {
  background: linear-gradient(135deg, rgba(227, 168, 81, 0.22), rgba(196, 132, 47, 0.10));
  border-color: rgba(167, 107, 33, 0.38);
  box-shadow: 0 2px 14px rgba(196, 132, 47, 0.14);
}

.freeform-save-realtime-tag {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 2px 9px 3px;
  font-size: 10px;
  font-style: normal;
  font-weight: 800;
  letter-spacing: 0.14em;
  line-height: 1.2;
  background: linear-gradient(135deg, #e3a851, #c4842f);
  color: #fff;
  border-radius: 999px;
  vertical-align: middle;
  box-shadow:
    0 1px 4px rgba(196, 132, 47, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
  text-shadow: 0 1px 1px rgba(102, 60, 16, 0.28);
}

.freeform-save-realtime-copy {
  display: flex;
  align-items: center;
  min-width: 0;
}

.freeform-save-realtime-title {
  color: var(--ff-board-text-strong);
  font-size: 12px;
  font-weight: 800;
}

/* The ON/OFF subtitle pushed the title onto a second visual line; the
   toggle's track + thumb already convey state, so the text is hidden. */
.freeform-save-realtime-state {
  display: none;
}

.freeform-save-realtime-switch {
  width: 48px;
  height: 27px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  flex: 0 0 auto;
}

.freeform-save-realtime-track {
  position: relative;
  display: block;
  width: 48px;
  height: 27px;
  border-radius: 999px;
  background: var(--ff-board-hover-strong);
  border: 1px solid var(--ff-board-border-strong);
  transition: background 0.18s ease, border-color 0.18s ease;
}

.freeform-save-realtime-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 19px;
  height: 19px;
  border-radius: 999px;
  background: var(--ff-board-surface);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
  transition: transform 0.18s ease, background 0.18s ease;
}

.freeform-save-realtime-switch.active .freeform-save-realtime-track {
  /* Warm earthy amber when the realtime board is on — formas-brand
     ochre gradient with a slightly darker rim for depth. */
  background: linear-gradient(135deg, #e3a851, #c4842f);
  border-color: #a76b21;
  box-shadow: 0 1px 6px rgba(196, 132, 47, 0.35);
}

.freeform-save-realtime-switch.active .freeform-save-realtime-thumb {
  transform: translateX(21px);
  background: #fff8ec;
}

.freeform-save-preview {
  border: 1px dashed var(--ff-board-border-strong);
  border-radius: 11px;
  background: var(--ff-board-surface-softer);
  color: var(--ff-board-text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 10px 12px;
}

.freeform-save-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.freeform-save-action {
  border: none;
  border-radius: 999px;
  padding: 11px 18px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.25px;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.freeform-save-action.cancel {
  background: var(--ff-board-surface-soft);
  color: var(--ff-board-text-muted);
}

.freeform-save-action.cancel:hover {
  background: var(--ff-board-hover-strong);
  color: var(--ff-board-text-strong);
}

.freeform-save-action.confirm {
  background: var(--ff-board-selection);
  color: var(--ff-board-selection-contrast);
}

.freeform-save-action.confirm:hover {
  background: var(--ff-board-text);
  transform: translateY(-1px);
}

/* Non-blocking recovery prompt for newer autosave backup */
.freeform-autosave-recovery {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(14px);
  opacity: 0;
  z-index: 2147483647;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.freeform-autosave-recovery.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.freeform-autosave-recovery-inner {
  min-width: 300px;
  max-width: min(640px, calc(100vw - 30px));
  background: var(--ff-board-surface);
  border: 1px solid var(--ff-board-border);
  border-radius: 13px;
  box-shadow: var(--ff-board-shadow-soft);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.freeform-autosave-recovery-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.freeform-autosave-recovery-text strong {
  color: var(--ff-board-text-strong);
  font-size: 12px;
}

.freeform-autosave-recovery-text span {
  color: var(--ff-board-text-muted);
  font-size: 11px;
}

.freeform-autosave-recovery-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.freeform-autosave-btn {
  border: none;
  border-radius: 999px;
  padding: 9px 12px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.freeform-autosave-btn.keep {
  background: var(--ff-board-surface-soft);
  color: var(--ff-board-text-muted);
}

.freeform-autosave-btn.recover {
  background: var(--ff-board-selection);
  color: var(--ff-board-selection-contrast);
}

@media (max-width: 700px) {
  .freeform-save-panel {
    width: calc(100vw - 20px);
    padding: 16px;
    border-radius: 14px;
  }

  .freeform-save-modes {
    grid-template-columns: 1fr;
  }

  .freeform-save-actions {
    flex-direction: column-reverse;
  }

  .freeform-save-action {
    width: 100%;
  }

  .freeform-autosave-recovery {
    bottom: 12px;
  }

  .freeform-autosave-recovery-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .freeform-autosave-recovery-actions {
    width: 100%;
  }

  .freeform-autosave-btn {
    flex: 1;
  }
}

/* Generic Action Modal (Confirm / Prompt) - LIGHT THEME */
.freeform-action-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2147483647; /* CRITICAL: Maximum z-index to be above iconBar */
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.freeform-action-modal.visible {
  opacity: 1;
}

.freeform-action-content {
  background: var(--ff-board-surface);
  border: 1px solid var(--ff-board-border);
  border-radius: 20px;
  padding: 28px;
  width: 90%;
  max-width: 420px;
  box-shadow: var(--ff-board-shadow);
  transform: scale(0.95);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.freeform-action-modal.visible .freeform-action-content {
  transform: scale(1);
}

.freeform-action-title {
  color: var(--ff-board-text);
  font-size: 18px;
  font-weight: 700;
  margin: 0;
}

.freeform-action-title-inner {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.freeform-action-title-icon {
  width: 20px;
  height: 20px;
  display: inline-block;
  filter: var(--ff-board-icon-filter);
  opacity: 0.7;
}

.freeform-action-message {
  color: var(--ff-board-text-muted);
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
}

.freeform-action-input {
  background: var(--ff-board-input-bg);
  border: 1px solid var(--ff-board-border);
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--ff-board-text);
  font-size: 15px;
  width: 100%;
  outline: none;
  transition: all 0.2s;
}

.freeform-action-input:focus {
  border-color: var(--ff-board-selection);
  background: var(--ff-board-input-focus-bg);
  box-shadow: var(--ff-board-input-focus-ring);
}

.freeform-action-input::placeholder {
  color: var(--ff-board-text-soft);
}

/* Discrete overwrite hint pill */
.freeform-overwrite-hint {
  margin-top: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--ff-board-surface-soft);
  border: 1px solid var(--ff-board-border-soft);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--ff-board-text-muted);
}

.freeform-overwrite-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--ff-board-selection);
}

.freeform-overwrite-text {
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 600;
}

.freeform-action-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.freeform-action-btn {
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  letter-spacing: 0.3px;
}

.freeform-action-btn.cancel {
  background: var(--ff-board-surface-soft);
  color: var(--ff-board-text-muted);
}

.freeform-action-btn.cancel:hover {
  background: var(--ff-board-hover-strong);
  color: var(--ff-board-text);
}

.freeform-action-btn.confirm {
  background: var(--ff-board-selection);
  color: var(--ff-board-selection-contrast);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.freeform-action-btn.confirm:hover {
  background: var(--ff-board-text);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.freeform-action-btn.danger {
  background: var(--ff-board-danger);
  color: #fff;
}

.freeform-action-btn.danger:hover {
  background: var(--ff-board-danger-hover);
}

/* ============================================================
   FREEFORM LIBRARY LOADING OVERLAY - LIGHT THEME
   ============================================================ */

/* Loader occupying the board-grid area until the list finishes loading */
.library-list-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  padding: 40px;
}

/* Count authority resolves independently from the first board metadata page. */

@media (prefers-reduced-motion: reduce) {
  .library-item.board-delete-exit {
    transition: none;
  }

  .library-count.is-count-pending::after,
  .library-tab-count.is-count-pending::after {
    animation: none;
  }
}

.freeform-load-overlay {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  background: var(--ff-board-surface-strong) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 100 !important;
  border-radius: 0 !important;
  box-sizing: border-box !important;
  padding: 20px !important;
}

.freeform-load-pill {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 12px !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
}

/* Dark spinning circle */
.freeform-load-spinner {
  width: 40px !important;
  height: 40px !important;
  border: 3px solid var(--ff-board-spinner-track) !important;
  border-top-color: var(--ff-board-spinner-head) !important;
  border-radius: 50% !important;
  animation: freeform-spin 0.8s linear infinite !important;
  box-sizing: border-box !important;
}

/* LOADING text */
.freeform-load-text {
  color: var(--ff-board-text) !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  letter-spacing: 2px !important;
  text-transform: uppercase !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  padding: 0 8px !important;
  line-height: 1.4 !important;
  text-align: center !important;
  white-space: normal !important;
  overflow-wrap: normal !important;
}

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

@keyframes slideUp {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Hide hover gradient when loading */
.library-item.loading .item-preview::before {
  opacity: 0 !important; 
}

/* Success state for loaded board */
.freeform-load-overlay.success .freeform-load-spinner {
  border-color: transparent !important;
  border-top-color: transparent !important;
  animation: none !important;
  background: var(--ff-board-success) !important;
  width: 32px !important;
  height: 32px !important;
}

.freeform-load-overlay.success .freeform-load-spinner::after {
  content: '✓' !important;
  color: white !important;
  font-size: 16px !important;
  font-weight: bold !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 100% !important;
  height: 100% !important;
}

.freeform-load-overlay.success .freeform-load-text {
  color: var(--ff-board-success) !important;
}

/* Thin black progress line on board card thumbnail */
.freeform-card-progress-wrap {
  position: absolute !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  height: 3px !important;
  background: var(--ff-board-progress-track) !important;
  z-index: 200 !important;
  border-radius: 0 !important;
}

.freeform-card-progress-bar {
  height: 100% !important;
  width: 0%;
  background: var(--ff-board-progress-bar) !important;
  border-radius: 0 !important;
  transition: width 0.3s linear !important;
}

.freeform-card-progress-pct {
  position: absolute !important;
  bottom: 8px !important;
  right: 8px !important;
  font-size: 10px !important;
  font-weight: 800 !important;
  color: var(--ff-board-text-strong) !important;
  letter-spacing: 0.5px !important;
  z-index: 200 !important;
}

/* --------------------------------------------------------------------------
   Global Freeform Status Pill (Saving) - LIGHT THEME
   -------------------------------------------------------------------------- */
.freeform-status-pill {
  --ff-status-canvas-left: 0px;
  --ff-status-canvas-right: 0px;
  position: fixed;
  left: calc(
    var(--ff-status-canvas-left) +
      (100vw - var(--ff-status-canvas-left) - var(--ff-status-canvas-right)) / 2
  );
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2147483647; /* CRITICAL: Maximum z-index to be above iconBar */
  pointer-events: none;
  opacity: 1;
  transition:
    opacity 0.2s ease,
    left 0.22s cubic-bezier(0.32, 0.72, 0, 1),
    transform 0.2s ease;
}

/* Match Viewer Mode: center status in the usable canvas, not the browser viewport. */
@media (min-width: 769px) {
  body:has(.sidebar.open) .freeform-status-pill {
    --ff-status-canvas-left: var(--sidebar-width, 260px);
  }

  body:has(.main-content.generations-open) .freeform-status-pill {
    --ff-status-canvas-right: var(--capsule-panel-width, 242px);
  }
}

.freeform-status-pill--closing {
  opacity: 0;
  transform: translate(-50%, calc(-50% + 8px));
}

.freeform-status-pill-inner {
  background: var(--ff-board-surface-strong);
  border-radius: 999px;
  border: 1px solid var(--ff-board-border);
  padding: 12px 22px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--ff-board-shadow-soft);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  min-width: 220px;
}

.freeform-status-spinner {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid var(--ff-board-spinner-track);
  border-top-color: var(--ff-board-spinner-head);
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.freeform-status-text {
  color: var(--ff-board-text);
  font-size: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-weight: 700;
}

.freeform-status-copy {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.freeform-status-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}

.freeform-status-progress-value {
  color: var(--ff-board-text-muted);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
  line-height: 1;
  flex: none;
}

.freeform-status-progress-value[hidden] {
  display: none;
}

.freeform-status-progress {
  width: 100%;
  height: 2px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--ff-board-progress-track);
}

.freeform-status-progress[hidden] {
  display: none;
}

.freeform-status-progress span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--ff-board-spinner-head);
  transition: width 0.18s ease;
}

.freeform-status-pill--success .freeform-status-pill-inner {
  border-color: var(--ff-board-success-border);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}

.freeform-status-pill--success .freeform-status-text {
  color: var(--ff-board-success);
}

.freeform-status-pill--success .freeform-status-progress span {
  background: var(--ff-board-success);
}

.freeform-status-pill--error .freeform-status-pill-inner {
  border-color: rgba(220, 38, 38, 0.3);
}

.freeform-status-pill--error .freeform-status-text {
  color: #dc2626;
}

.freeform-status-pill--error .freeform-status-progress span {
  background: var(--ff-board-danger-hover);
}

.legacy-realtime-modal {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(12, 14, 18, 0.34);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.16s ease;
}

.legacy-realtime-modal.visible {
  opacity: 1;
}

.legacy-realtime-panel {
  width: min(456px, calc(100vw - 36px));
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.24);
  color: #20242a;
  padding: 22px;
  transform: translateY(8px) scale(0.98);
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

.legacy-realtime-modal.visible .legacy-realtime-panel {
  transform: translateY(0) scale(1);
}

.legacy-realtime-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(173, 129, 45, 0.26);
  background: rgba(173, 129, 45, 0.08);
  margin-bottom: 14px;
}

.legacy-realtime-mark img {
  width: 30px;
  height: 30px;
  display: block;
  object-fit: contain;
}

.legacy-realtime-copy {
  min-width: 0;
}

.legacy-realtime-eyebrow {
  color: #7a6028;
  font-size: 10px;
  line-height: 1.2;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 800;
  margin-bottom: 7px;
}

.legacy-realtime-copy h3 {
  margin: 0;
  color: #16191d;
  font-size: 20px;
  line-height: 1.18;
  font-weight: 760;
  letter-spacing: 0;
}

.legacy-realtime-copy p {
  margin: 9px 0 0;
  color: rgba(24, 27, 32, 0.68);
  font-size: 13px;
  line-height: 1.5;
}

.legacy-realtime-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
  flex-wrap: wrap;
}

.legacy-realtime-action {
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  padding: 0 13px;
  background: rgba(255, 255, 255, 0.72);
  color: rgba(20, 23, 28, 0.72);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease, transform 0.14s ease;
}

.legacy-realtime-action:hover {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.2);
  color: #111317;
  transform: translateY(-1px);
}

.legacy-realtime-action.primary {
  background: #1f2329;
  border-color: #1f2329;
  color: #fff;
}

.legacy-realtime-action.primary:hover {
  background: #111317;
  border-color: #111317;
}

.legacy-realtime-action.ghost {
  border-color: transparent;
  background: transparent;
  color: rgba(20, 23, 28, 0.54);
}

.legacy-realtime-modal[data-theme="dark"] .legacy-realtime-panel {
  background: rgba(22, 24, 31, 0.96);
  border-color: rgba(255, 255, 255, 0.14);
  color: #edf0f8;
  box-shadow: 0 24px 78px rgba(0, 0, 0, 0.58);
}

.legacy-realtime-modal[data-theme="dark"] .legacy-realtime-mark {
  border-color: rgba(210, 166, 70, 0.32);
  background: rgba(210, 166, 70, 0.14);
}

.legacy-realtime-modal[data-theme="dark"] .legacy-realtime-eyebrow {
  color: #e7c46f;
}

.legacy-realtime-modal[data-theme="dark"] .legacy-realtime-copy h3 {
  color: #f6f7fb;
}

.legacy-realtime-modal[data-theme="dark"] .legacy-realtime-copy p {
  color: rgba(237, 240, 248, 0.68);
}

.legacy-realtime-modal[data-theme="dark"] .legacy-realtime-action {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.14);
  color: rgba(237, 240, 248, 0.76);
}

.legacy-realtime-modal[data-theme="dark"] .legacy-realtime-action:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.24);
  color: #fff;
}

.legacy-realtime-modal[data-theme="dark"] .legacy-realtime-action.primary {
  background: #f6f7fb;
  border-color: #f6f7fb;
  color: #15171b;
}

.legacy-realtime-modal[data-theme="dark"] .legacy-realtime-action.ghost {
  background: transparent;
  border-color: transparent;
  color: rgba(237, 240, 248, 0.54);
}

/* Autosave Styles - LIGHT THEME */
.autosave-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--ff-board-surface-soft);
  color: var(--ff-board-text-muted);
  font-size: 9px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.5px;
  z-index: 10;
  pointer-events: none;
  border: 1px solid var(--ff-board-border);
}

.library-item.autosave-item {
  border-color: var(--ff-board-border);
}

.library-item.autosave-item:hover {
  border-color: var(--ff-board-border-strong);
}

/* Board trash confirmation */
.delete-confirmation-pill {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 2147483647; /* CRITICAL: Maximum z-index to be above iconBar */
  background: rgba(15, 18, 24, 0.28);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  opacity: 0;
  transform: none;
  transition: opacity 0.14s ease;
}

.delete-confirmation-pill.active {
  opacity: 1;
  transform: none;
}

.confirm-pill-container {
  width: min(340px, calc(100vw - 32px));
  display: grid;
  gap: 14px;
  background: var(--ff-board-surface);
  border: 1px solid var(--ff-board-border);
  border-radius: 12px;
  padding: 14px;
  box-shadow: var(--ff-board-shadow-soft);
  transform: translateY(4px) scale(0.985);
  transition: transform 0.14s ease;
  animation: none;
}

.delete-confirmation-pill.active .confirm-pill-container {
  transform: none;
}

.confirm-pill-head {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.confirm-pill-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(239, 68, 68, 0.09);
  color: var(--ff-board-danger);
  border: 1px solid rgba(239, 68, 68, 0.16);
}

.confirm-pill-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.confirm-pill-title {
  color: var(--ff-board-text);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
}

.confirm-pill-subtitle {
  color: var(--ff-board-text-muted);
  font-size: 11px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.confirm-pill-caption {
  color: var(--ff-board-text-softer);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
}

.confirm-pill-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.confirm-pill-btn {
  min-height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
  letter-spacing: 0;
}

.confirm-pill-btn.confirm-no {
  background: var(--ff-board-surface-soft);
  color: var(--ff-board-text-muted);
  border-color: var(--ff-board-border-soft);
}

.confirm-pill-btn.confirm-no:hover {
  background: var(--ff-board-hover-strong);
  color: var(--ff-board-text);
}

.confirm-pill-btn.confirm-yes {
  background: var(--ff-board-danger);
  color: white;
  border-color: var(--ff-board-danger);
}

.confirm-pill-btn.confirm-yes:hover {
  background: var(--ff-board-danger-hover);
  border-color: var(--ff-board-danger-hover);
}

/* New Board modal */
.new-board-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100002;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.new-board-modal {
  background: var(--ff-board-surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 24px;
  padding: 32px;
  max-width: 400px;
  width: 90%;
  border: 1px solid var(--ff-board-border);
  box-shadow: var(--ff-board-shadow);
  text-align: center;
  transform: scale(0.9) translateY(10px);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.new-board-modal-icon {
  width: 48px;
  height: 48px;
  background: var(--ff-board-surface-soft);
  border: 1px solid var(--ff-board-border-soft);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  color: var(--ff-board-text);
}

.new-board-modal-title {
  color: var(--ff-board-text);
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 12px;
  font-family: system-ui;
}

.new-board-modal-message {
  color: var(--ff-board-text-muted);
  font-size: 13px;
  margin: 0 0 24px;
  line-height: 1.5;
  font-family: system-ui;
}

.new-board-modal-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 22px;
  text-align: left;
}

.new-board-modal-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--ff-board-text);
  font-family: system-ui;
}

.new-board-modal-input {
  width: 100%;
  box-sizing: border-box;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--ff-board-border-strong);
  background: var(--ff-board-input-bg);
  color: var(--ff-board-text);
  font-size: 13px;
  font-weight: 600;
  padding: 0 12px;
  outline: none;
  font-family: system-ui;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.new-board-modal-input:focus {
  border-color: var(--ff-board-selection);
  box-shadow: var(--ff-board-input-focus-ring);
  background: var(--ff-board-input-focus-bg);
}

.new-board-modal-input::placeholder {
  color: var(--ff-board-text-soft);
}

.new-board-modal-hint {
  font-size: 11px;
  color: var(--ff-board-text-soft);
  font-family: system-ui;
}

.new-board-modal-realtime {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 24px;
  padding: 12px 14px;
  border: 1px solid var(--ff-board-border-soft);
  border-radius: 14px;
  background: var(--ff-board-surface-softer);
  text-align: left;
  transition:
    background 380ms cubic-bezier(0.32, 0.72, 0, 1),
    border-color 380ms cubic-bezier(0.32, 0.72, 0, 1),
    box-shadow 380ms cubic-bezier(0.32, 0.72, 0, 1);
}

.new-board-modal-realtime.active {
  background: linear-gradient(135deg, rgba(227, 168, 81, 0.22), rgba(196, 132, 47, 0.10));
  border-color: rgba(167, 107, 33, 0.38);
  box-shadow: 0 2px 14px rgba(196, 132, 47, 0.14);
}

.new-board-modal-realtime-tag {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 2px 9px 3px;
  font-size: 10px;
  font-style: normal;
  font-weight: 800;
  letter-spacing: 0.14em;
  line-height: 1.2;
  background: linear-gradient(135deg, #e3a851, #c4842f);
  color: #fff;
  border-radius: 999px;
  vertical-align: middle;
  box-shadow:
    0 1px 4px rgba(196, 132, 47, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
  text-shadow: 0 1px 1px rgba(102, 60, 16, 0.28);
}

.new-board-modal-realtime-copy {
  display: flex;
  align-items: center;
  min-width: 0;
}

.new-board-modal-realtime-title {
  color: var(--ff-board-text);
  font-family: system-ui;
  font-size: 13px;
  font-weight: 800;
}

/* The ON/OFF subtitle pushed the title onto a second line; the toggle
   itself conveys the state, so the text is hidden. */
.new-board-modal-realtime-state {
  display: none;
}

.new-board-modal-switch {
  width: 50px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  flex: 0 0 auto;
}

.new-board-modal-switch-track {
  position: relative;
  display: block;
  width: 50px;
  height: 28px;
  border-radius: 999px;
  background: var(--ff-board-hover-strong);
  border: 1px solid var(--ff-board-border-strong);
  transition: background 0.18s ease, border-color 0.18s ease;
}

.new-board-modal-switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--ff-board-surface);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
  transition: transform 0.18s ease, background 0.18s ease;
}

.new-board-modal-switch.active .new-board-modal-switch-track {
  /* Warm earthy amber when the realtime board is on — matches the save
     pill so the on-state colour is consistent across modals. */
  background: linear-gradient(135deg, #e3a851, #c4842f);
  border-color: #a76b21;
  box-shadow: 0 1px 6px rgba(196, 132, 47, 0.35);
}

.new-board-modal-switch.active .new-board-modal-switch-thumb {
  transform: translateX(22px);
  background: #fff8ec;
}

.new-board-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.new-board-modal-btn {
  padding: 12px 24px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: system-ui;
  transition: all 0.2s ease;
}

.new-board-modal-btn.secondary {
  background: var(--ff-board-surface-soft);
  border: 1px solid var(--ff-board-border);
  color: var(--ff-board-text-muted);
}

.new-board-modal-btn.secondary:hover {
  background: var(--ff-board-hover-strong);
  border-color: var(--ff-board-border-strong);
  color: var(--ff-board-text);
}

.new-board-modal-btn.primary {
  background: var(--ff-board-selection);
  border: none;
  color: var(--ff-board-selection-contrast);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.new-board-modal-btn.primary:hover {
  background: var(--ff-board-text);
  transform: translateY(-1px);
}

.new-board-modal-btn.secondary.danger {
  color: #e74c3c;
  border-color: rgba(231, 76, 60, 0.3);
}

.new-board-modal-btn.secondary.danger:hover {
  background: rgba(231, 76, 60, 0.12);
  border-color: rgba(231, 76, 60, 0.5);
  color: #c0392b;
}

/* Beta label - for use in freeform context */
.freeform-beta-label {
  font-size: 9px;
  color: var(--ff-board-text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--ff-board-surface-soft);
  padding: 2px 6px;
  border-radius: 6px;
  margin-left: 8px;
  border: 1px solid var(--ff-board-border-soft);
}

/* =====================================================
   PHASE 3: ACCESSIBILITY PREFERENCE QUERIES
   ===================================================== */

/* Respect users who prefer less animation. Keep essential feedback
   (loading spinner, progress bar) but drop decorative transforms. */
@media (prefers-reduced-motion: reduce) {
  .library-item,
  .library-item:hover,
  .item-preview img,
  .library-item:hover .item-preview img,
  .library-close,
  .library-close:hover,
  .library-item.loading,
  .freeform-save-action.confirm:hover,
  .freeform-action-btn.confirm:hover,
  .confirm-pill-btn.confirm-yes:hover,
  .new-board-modal-btn.primary:hover,
  .new-board-modal,
  .freeform-save-panel,
  .freeform-action-content,
  .freeform-autosave-recovery,
  .delete-confirmation-pill,
  .library-list-refresh-card,
  .skeleton-preview,
  .skeleton-line,
  .library-list.list-view .library-item-skeleton.list-skeleton .skeleton-actions span {
    transform: none !important;
    transition: none !important;
    animation: none !important;
  }

  .library-item.active::after {
    animation: none !important;
  }

  .item-name[data-tooltip]:hover::after {
    animation: none !important;
    opacity: 1;
    transform: none;
  }

  /* Keep the load spinner spinning — it is functional status feedback
     and stopping it would falsely suggest the load is complete. */
}

/* Respect users who prefer less transparency. Heavy backdrop blur
   causes readability issues on some displays and is disorienting for
   vestibular-sensitive users; provide opaque fallbacks. */
@media (prefers-reduced-transparency: reduce) {
  .freeform-library-backdrop,
  .freeform-save-modal,
  .freeform-action-modal,
  .new-board-modal-backdrop {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(0, 0, 0, 0.7);
  }

  .freeform-library-modal,
  .freeform-save-panel,
  .freeform-action-content,
  .new-board-modal,
  .freeform-status-pill-inner,
  .confirm-pill-container,
  .freeform-autosave-recovery-inner,
  .action-btn {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--ff-board-surface);
  }
}
