:root {
  /* Background */
  --bg-canvas: #FBFBFA;
  --bg-surface: #FFFFFF;
  --bg-subtle: #F6F6F5;
  --bg-hover: #F4F3F1;

  /* Text */
  --text-primary: #141312;    /* almost-black for crisp readability */
  --text-secondary: #52504B;  /* neutral dark gray for body copy */
  --text-tertiary: #918D88;   /* muted gray for meta text */
  --text-inverse: #FFFFFF;

  /* Borders */
  --border-default: #E9E9E7;
  --border-subtle: #F0EFEE;

  /* Brand & accents (calm, professional) */
  --brand: #122B44;           /* deep navy */
  --brand-hover: #0f2438;
  --brand-subtle: #F1F5F8;
  --accent: #1E3A5F;          /* reserved accent (used for focus, small highlights) */
  --accent-subtle: rgba(30,58,95,0.06);

  /* Selection */
  --selection: #1E3A5F;
  --selection-subtle: rgba(30,58,95,0.08);

  /* Semantic role colors (kept for diagram consistency) */
  --role-claim: #991B1B;
  --role-subclaim: #92400E;
  --role-rule: #1E40AF;
  --role-exception: #7E22CE;
  --role-evidence: #166534;
  --role-counterargument: #9F1239;

  /* Shadows - neutral */
  --shadow-sm: 0 1px 2px rgba(16, 20, 24, 0.04);
  --shadow-md: 0 6px 18px rgba(16, 20, 24, 0.06);
  --shadow-lg: 0 10px 30px rgba(16, 20, 24, 0.08);
  --shadow-xl: 0 18px 48px rgba(16, 20, 24, 0.10);

  /* Transitions */
  --transition-fast: 140ms ease;
  --transition-normal: 220ms cubic-bezier(.0,.0,.15,1);
  --transition-micro: 120ms cubic-bezier(0,0,0.15,1);

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  /* Spacing */
  --space-xs: 6px;
  --space-sm: 12px;
  --space-md: 20px;
  --space-lg: 28px;
  --space-xl: 40px;
}


html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
/* Breadcrumb Trail */


.breadcrumb-item {
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

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

.breadcrumb-item.active {
  color: var(--text-primary);
  font-weight: 600;
  background: var(--bg-subtle);
}

.breadcrumb-separator {
  color: var(--text-tertiary);
  font-size: 10px;
  user-select: none;
}

/* toolbar: fixed single-row bar — never vertically scrolls or wraps */
#toolbar {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);

  display: flex;
  gap: 8px;
  align-items: center;
  z-index: 2000;

  background: var(--bg-surface);
  padding: 8px 12px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-default);

  /* Prevent any vertical growth or wrapping */
  flex-wrap: nowrap;        /* never wrap to next line */
  white-space: nowrap;      /* prevent inline wrapping */
  overflow-x: auto;         /* allow horizontal scrolling if buttons overflow */
  overflow-y: hidden;       /* absolutely prevent vertical scrolling from toolbar */

  /* keep toolbar visually within viewport but not tall */
  max-height: 56px;
  line-height: 1;

  -webkit-overflow-scrolling: touch;
}

/* hide vertical scrollbar if a browser would show it */
#toolbar::-webkit-scrollbar {
  height: 8px;
}
#toolbar::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.08);
  border-radius: 8px;
}

/* make sure .dropdown (button wrapper) does not clip its absolutely-positioned children */
.dropdown {
  position: relative;
  display: inline-block;
  overflow: visible; /* allow dropdowns placed on body to appear without clipping */
}



#toolbar button {
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: all var(--transition-fast);
}

#toolbar button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  transition: background var(--transition-micro), color var(--transition-micro);
}

#toolbar button:focus-visible {
  outline: 2px solid var(--selection);
  outline-offset: 2px;
  background: var(--bg-hover);
}

#toolbar button:active {
  background: var(--bg-subtle);
}

#toolbar button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#toolbar button:disabled:hover {
  background: transparent;
  color: var(--text-secondary);
}

/* Template Dropdown */
.dropdown {
  position: relative;
  display: inline-block;
}

#templateBtn {
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: all var(--transition-fast);
}

#templateBtn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* dropdown overlays the canvas, constrained and scrollable if content is large */
.dropdown-menu {
  display: none;
  visibility: hidden;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);

  /* keep dropdown reasonably sized — scroll inside if there are many items */
  min-width: 220px;
  max-width: 520px;
  max-height: 60vh;

  z-index: 10000;                      /* very high so it overlays the canvas */
  overflow-y: auto;
  overflow-x: hidden;
}


.dropdown-menu.show {
  display: block;
  visibility: visible;
}

#templatePreview {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-subtle);
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition-fast);
  pointer-events: none;
}

#templatePreview.visible {
  opacity: 1;
}

#templatePreview svg {
  transition: transform var(--transition-fast);
}

#templatePreview.visible svg {
  transform: scale(1.02);
}

.dropdown-item {
  padding: 12px var(--space-md);
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.1s ease;
  position: relative;
}

.dropdown-item:last-child {
  border-bottom: none;
}

.dropdown-item:hover {
  background: #F0EFEE;
}

.dropdown-item:active {
  background: #E5E5E4;
}

.dropdown-item.selected {
  background: #E5E5E4;
}

.dropdown-item.selected::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}


.dropdown-item strong {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.dropdown-item span {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: var(--text-secondary);
}

#statusLabel {
  margin-left: 16px;
  color: #6b6560;
  font-size: 13px;
  font-family: 'Crimson Text', serif;
  font-style: italic;
}

/* Reset view button */
#resetViewBtn {
  flex-shrink: 0;
}

#resetViewBtn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Add Arm button */
#addArmBtn {
  position: fixed;
  bottom: 56px;
  right: 20px;
  z-index: 2000;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--text-inverse);
  font-family: 'Inter', sans-serif;
  font-size: 24px;
  font-weight: 400;
  line-height: 48px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-md);
}

#addArmBtn:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-lg);
  transform: scale(1.05);
}

#addArmBtn:active {
  transform: scale(1);
  box-shadow: var(--shadow-md);
}
/* SVG */
#whirlybird {
  width: 100%;
  height: 100%;
  visibility: hidden;
  background-color: #f9f8f4; 
  background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M 40 0 L 0 0 0 40' fill='none' stroke='%23eeedea' stroke-width='0.3'/%3E%3C/svg%3E");
  image-rendering: crisp-edges;
  display: block;
  will-change: auto;
}

#whirlybird.canvas-ready {
  visibility: visible;
}

#whirlybird.panning {
  cursor: grabbing !important;
}

/* ARM visuals - clean, precise lines */
.arm {
  fill: none;
  stroke: #4a4745;
  stroke-width: 2.5;
  will-change: stroke, stroke-width;
  opacity: 1;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: visiblePainted;
  paint-order: stroke fill markers;
  transition: stroke var(--transition-fast), stroke-width var(--transition-fast);
}

/* Root arms slightly thicker */
use.arm {
  fill: none !important;
  stroke-width: 3;
  paint-order: stroke fill markers;
}

/* Higher z-index for selected/typing arms */
.arm.selected,
.arm.typing {
  z-index: 100;
  paint-order: stroke fill markers;
}

/* Hover - subtle darkening */
.arm.hover {
  stroke: #A8A29E;
  stroke-width: 3;
}

/* Selected - accent color, no animation */
.arm.selected {
  stroke-width: 3;
  stroke: #4a4745;
  

}

/* Outline - selection indicator */
.outline-arm {
  fill: none;
  stroke: var(--selection);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
  opacity: 0.9;
}

/* Hitbox */
.arm-hitbox {
  fill: none;
  stroke: transparent;
  stroke-width: 80;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: stroke;
  cursor: pointer;
  z-index: 50;
}

.arm-hitbox.over-label {
  cursor: text;
}


/* Dragger */
.arm-dragger {
  fill: var(--bg-surface);
  stroke: var(--border-default);
  stroke-width: 1.5;
  pointer-events: all;
  cursor: grab;
  opacity: 0;
  transition: opacity var(--transition-fast);
  r: 8;
}

.arm-dragger:hover {
  opacity: 1;
  stroke: var(--accent);
}

.arm-dragger:active {
  cursor: grabbing;
  fill: var(--accent-subtle);
}

/* Center circle - clean, minimal */
.center {
  fill: #FFFFFE;
  stroke: #C8C3BB;
  stroke-width: 1.5;
  filter: drop-shadow(0 1px 4px rgba(26, 22, 20, 0.06));
  transition: all var(--transition-fast);
}

.center:hover {
  stroke: #B8B1A8;
}
/* Label - clean sans-serif, uppercase for diagram */
.label {
  font-size: 18px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  fill: var(--text-primary);
  user-select: none;
  pointer-events: auto;
  cursor: text;
  z-index: 100;
  letter-spacing: 0.08em;
  text-transform: none;
  text-anchor: middle;
  dominant-baseline: auto;
}



/* Caret */
#caret {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  visibility: hidden;
  animation: caretBlink 1s step-end infinite;
}

@keyframes caretBlink {
  0%, 50% { 
    opacity: 1;
  }
  51%, 100% { 
    opacity: 0;
  }
}

/* Center text */
#centerText {
  width: 100%;
  height: 100%;
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  word-break: break-word;
  color: var(--text-primary);
}

/* Context menu */
#contextMenu, #typeSubmenu {
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.menu-item, .submenu-item {
  padding: 10px 16px;
  cursor: pointer;
  user-select: none;
  color: var(--text-primary);
  transition: background var(--transition-micro), padding-left var(--transition-micro);
  font-weight: 500;
}

.menu-item:hover, .submenu-item:hover {
  background: var(--bg-hover);
  padding-left: 20px;
}

.menu-item:active, .submenu-item:active {
  background: var(--bg-subtle);
  padding-left: 16px;
}

/* Tooltip */
#armTooltip {
  position: fixed;
  pointer-events: none;
  background: var(--text-primary);
  color: var(--text-inverse);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--transition-micro), transform var(--transition-micro);
  z-index: 5000;
  white-space: nowrap;
}

#armTooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

#armTooltip.visible {
  opacity: 1;
}

/* Dashed attack arms - subtle */
.arm.attack {
  stroke-dasharray: 12, 8;
  opacity: 0.7;
}

/* Notes Panel - floating card */
#notesPanel {
  position: fixed;
  right: 20px;
  top: 72px;
  bottom: 52px;
  width: 380px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  z-index: 1500;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateX(20px);
  pointer-events: none;
  transition: opacity var(--transition-normal), transform var(--transition-normal);
}
#notesPanel.open {
  opacity: 1;
  transform: translateX(0);
  pointer-events: all;
}

#notesPanelHeader {
  padding: 14px var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  gap: 10px;
}

#notesPanelHeaderLeft {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

#closePanelBtn {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  line-height: 28px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#closePanelBtn:hover {
  color: var(--text-primary);
}

#notesPanelContent {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

/* Notes Toolbar - minimal inline */
#notesToolbar {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 8px var(--space-lg);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  border-radius: 0;
  flex-shrink: 0;
}

.format-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color var(--transition-fast);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 0;
}

.format-btn:hover {
  color: var(--text-primary);
}

.format-btn.active {
  color: var(--accent);
  background: transparent;
}

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

.format-btn span {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 600;
}

#noteText::-webkit-scrollbar {
  width: 8px;
}

#noteText::-webkit-scrollbar-track {
  background: rgba(212, 207, 199, 0.2);
  border-radius: 4px;
}

#noteText::-webkit-scrollbar-thumb {
  background: rgba(184, 147, 95, 0.4);
  border-radius: 4px;
}

#noteText::-webkit-scrollbar-thumb:hover {
  background: rgba(184, 147, 95, 0.6);
}

#noteText {
  flex: 1;
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  border: none;
  border-radius: 0;
  font-family: 'IBM Plex Serif', Georgia, serif;
  font-size: 14px;
  line-height: 1.8;
  outline: none;
  color: var(--text-primary);
  background: transparent;
  box-sizing: border-box;
  overflow-y: auto;
  overflow-x: hidden;
  word-wrap: break-word;
}

#noteText:focus {
  /* No visible focus ring - the panel context is enough */
}

/* Placeholder for contenteditable */
#noteText:empty:before {
  content: attr(data-placeholder);
  color: var(--text-tertiary);
  font-style: normal;
  font-weight: 400;
  pointer-events: none;
}

/* Rich text formatting within notes */
#noteText strong, #noteText b {
  font-weight: 700;
  color: #2a2621;
}

#noteText em, #noteText i {
  font-style: italic;
  color: #4a3f35;
}

#noteText u {
  text-decoration: underline;
  text-decoration-color: #b8935f;
}

#noteText ul, #noteText ol {
  margin: 12px 0;
  padding-left: 24px;
}

#noteText li {
  margin: 6px 0;
}

#noteText ul li {
  list-style-type: disc;
}

#noteText ol li {
  list-style-type: decimal;
}

#noteText:focus {
  border-color: transparent;
  box-shadow: none;
}

#noteText::placeholder {
  color: #a09a92;
  font-style: italic;
}

/* Outline Panel - floating card */
#outlinePanel {
  position: fixed;
  left: 20px;
  top: 72px;
  bottom: 52px;
  width: 360px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  z-index: 1500;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateX(-20px);
  pointer-events: none;
  transition: opacity var(--transition-normal), transform var(--transition-normal);
}

#outlinePanelContent {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  scroll-behavior: smooth;
}

#outlinePanelContent::-webkit-scrollbar {
  width: 8px;
}

#outlinePanelContent::-webkit-scrollbar-track {
  background: rgba(212, 207, 199, 0.2);
  border-radius: 4px;
}

#outlinePanelContent::-webkit-scrollbar-thumb {
  background: rgba(184, 147, 95, 0.4);
  border-radius: 4px;
}

#outlinePanelContent::-webkit-scrollbar-thumb:hover {
  background: rgba(184, 147, 95, 0.6);
}

#outlinePanel.open {
  opacity: 1;
  transform: translateX(0);
  pointer-events: all;
}

#outlinePanelHeader {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

#outlinePanelTitle {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-secondary);
  letter-spacing: 0;
  text-transform: none;
}

#closeOutlinePanelBtn {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  line-height: 28px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

#closeOutlinePanelBtn:hover {
  color: var(--text-primary);
}

#outlineTree {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  padding: var(--space-sm) var(--space-lg) var(--space-lg) var(--space-lg);
}

.outline-item {
  margin-bottom: 1px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
  font-weight: 400;
}

.outline-item::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 10px;
  background: var(--border-default);
  vertical-align: middle;
}

/* Color dots based on data attributes */
.outline-item[data-role="claim"]::before { background: var(--role-claim); }
.outline-item[data-role="subclaim"]::before { background: var(--role-subclaim); }
.outline-item[data-role="rule"]::before { background: var(--role-rule); }
.outline-item[data-role="exception"]::before { background: var(--role-exception); }
.outline-item[data-role="evidence"]::before { background: var(--role-evidence); }
.outline-item[data-role="counterargument"]::before { background: var(--role-counterargument); }
.outline-item[data-role="policy"]::before { background: var(--role-policy); }
.outline-item[data-role="analogy"]::before { background: var(--role-analogy); }

.outline-item:hover {
  background: var(--bg-hover);
  padding-left: 14px;
  transition: background var(--transition-micro), padding-left var(--transition-micro);
}

.outline-item:focus-visible {
  outline: 2px solid var(--selection);
  outline-offset: -2px;
}

.outline-item.active {
  background: var(--selection-subtle);
  font-weight: 600;
}

/* Template arm label in outline (Issue, Rule, Pro, Con, etc.) – subtle, non-cluttered */
.outline-template-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  opacity: 0.85;
  margin-right: 6px;
  vertical-align: baseline;
}

/* Drag and drop styles */
.outline-item[draggable="true"] {
  cursor: grab;
}

.outline-item.dragging {
  opacity: 0.4;
  cursor: grabbing;
}

/* DROP BEFORE - subtle line above */
.outline-item.drag-over-before {
  position: relative;
  margin-top: 6px;
}

.outline-item.drag-over-before::after {
  content: '';
  position: absolute;
  top: -4px;
  left: 12px;
  right: 12px;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
}

/* DROP AFTER - subtle line below */
.outline-item.drag-over-after {
  position: relative;
  margin-bottom: 6px;
}

.outline-item.drag-over-after::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 12px;
  right: 12px;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
}

/* DROP AS CHILD - subtle background highlight */
.outline-item.drag-over-child {
  background: var(--accent-subtle);
  border-left: 2px solid var(--accent);
  padding-left: 10px;
}

.outline-item.invalid-drop {
  cursor: not-allowed;
  opacity: 0.4;
  background: rgba(159, 18, 57, 0.06);
}

/* Visual feedback when arm is valid drop target */
.arm.drop-target {
  stroke: var(--accent) !important;
  stroke-width: 4;
}

/* Template Selector Modal */
#templateModal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(28, 25, 23, 0.8);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  animation: fadeIn var(--transition-normal);
}

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

#templateModalContent {
  background: var(--bg-surface);
  padding: var(--space-xl);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-width: 800px;
  border: 1px solid var(--border-default);
}

#templateModalContent h2 {
  font-family: 'Inter', sans-serif;
  font-size: 24px;
  color: var(--text-primary);
  margin: 0 0 4px 0;
  text-align: center;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.template-subtitle {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  margin: 0 0 var(--space-lg) 0;
  font-weight: 400;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

.template-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
}

.template-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.template-icon {
  margin: 0 auto var(--space-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.template-card h3 {
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  color: var(--text-primary);
  margin: 0 0 4px 0;
  font-weight: 600;
}

.template-desc {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 var(--space-md) 0;
  line-height: 1.5;
}

.arm-count {
  display: inline-block;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}
/* ============================
   Sliding outline & notes panels + triangle tabs
   Appended by: sliding-tabs feature
   ============================ */

/* ===== Sliding panels & inward-pointing triangle tabs ===== */

/* Base slide-panel: panels start offscreen and will slide in when .open is added */
.slide-panel {
  position: fixed;
  top: 64px;                      /* push below toolbar */
  bottom: 16px;                   /* breathing room from bottom */
  height: auto;                   /* let top+bottom define height */
  transform: translateX(0);       /* no vertical centering anymore */
  transition: transform 360ms cubic-bezier(.22,.9,.3,1);
  z-index: 1600;
  width: 360px;
  background: linear-gradient(to bottom, #fdfcfb 0%, #f7f6f4 100%);
  border: 1px solid #d4cfc7;
  box-shadow: 8px 0 24px rgba(42,38,33,0.10);
  overflow: hidden;
}

.slide-panel.left {
  left: 0;
  transform: translateX(calc(-100% + -5px));
}

.slide-panel.right {
  right: 0;
  transform: translateX(calc(100% - -5px));
}

.slide-panel.open {
  transform: translateX(0) !important;
}


/* ============================
   Floating Edge Triangles
============================ */
/* ============================
   Floating Edge Triangles
============================ */
.edge-tab {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  background: none;
  border-left: none;
  border-right: none;
  outline: none;
  box-shadow: none;
  padding: 0;
  cursor: pointer;
  z-index: 3000;
  transition: all var(--transition-normal);
}

/* Left edge triangle */
.edge-tab.left {
  left: 0;
  border-left: 12px solid var(--text-tertiary);
  opacity: 0.4;
  pointer-events: all;
}

.edge-tab.left:hover {
  opacity: 0.8;
  border-left-color: var(--accent);
  transform: translateY(-50%) translateX(4px);
}

/* Right edge triangle */
.edge-tab.right {
  right: 0;
  border-right: 12px solid var(--text-tertiary);
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-normal);
}

.edge-tab.right.visible {
  opacity: 0.4;
  pointer-events: all;
}

.edge-tab.right:hover {
  opacity: 0.8;
  border-right-color: var(--accent);
  transform: translateY(-50%) translateX(-4px);
}

/* When panels are open */
body.outline-open .edge-tab.left {
  opacity: 0.6;
  border-left-color: var(--accent);
  transform: translateY(-50%) rotate(180deg);
}

body.notes-open .edge-tab.right {
  opacity: 0.6;
  border-right-color: var(--accent);
  transform: translateY(-50%) rotate(180deg);
}

/* Mobile adjustments */
@media (max-width: 720px) {
  .edge-tab { border-top: 12px solid transparent; border-bottom: 12px solid transparent; }
  .slide-panel { width: 80%; height: calc(100% - 56px); }
}

/* Backdrop dimming when panels are open */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: transparent;
  pointer-events: none;
  transition: background var(--transition-normal);
  z-index: 1400;
}

/* Disable canvas dimming when panels open */
body.outline-open::before,
body.notes-open::before {
  background: transparent !important;
  pointer-events: none !important;
}

/* Mini-map at top of outline */
#outlineMinimap {
  padding: 16px 24px;
  border-bottom: 1px solid #e8e5e0;
  background: linear-gradient(to bottom, #fdfcfb 0%, #f8f6f3 100%);
}

#minimapCanvas {
  width: 100%;
  height: 120px;
  background: linear-gradient(to bottom, #ffffff 0%, #fdfcfb 100%);
  border: 1px solid #d4cfc7;
  border-radius: 8px;
  display: block;
  overflow: visible;
}

#minimapCanvas line,
#minimapCanvas circle.minimap-node {
  transition: opacity 0.2s ease, stroke-width 0.2s ease;
}

#minimapCanvas line:hover,
#minimapCanvas circle.minimap-node:hover {
  filter: drop-shadow(0 2px 4px rgba(184, 147, 95, 0.4));
}

/* Node properties section in notes panel */
.node-type-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-family: 'Inter', sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--text-primary);
  color: var(--text-inverse);
  flex-shrink: 0;
  white-space: nowrap;
}

.quick-label-edit {
  flex: 1;
  min-width: 0;
  padding: 5px 0;
  border: none;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  background: transparent;
  outline: none;
  transition: border-color var(--transition-fast);
}

.quick-label-edit:focus {
  border-bottom-color: var(--accent);
}

.quick-label-edit::placeholder {
  color: var(--text-tertiary);
  font-weight: 400;
}


/* Loading spinner (for future use) */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(184, 147, 95, 0.2);
  border-top-color: #b8935f;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ============================
   STATUS BAR
============================ */
#statusBar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 32px;
  background: #2A2825;
  border-top: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-md);
  z-index: 1900;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: var(--text-inverse);
  letter-spacing: 0;
  user-select: none;
  cursor: default;
}

#statusLeft,
#statusCenter,
#statusRight {
  display: flex;
  align-items: center;
  gap: 12px;
}

#statusLeft {
  flex: 1;
  justify-content: flex-start;
}

#statusCenter {
  flex: 1;
  justify-content: center;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-style: normal;
  color: var(--text-tertiary);
}

#statusRight {
  flex: 1;
  justify-content: flex-end;
}

.status-divider {
  color: rgba(255, 255, 255, 0.2);
  font-weight: 300;
}

#statusBar kbd {
  display: inline-block;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-inverse);
}

#zoomLevel,
#nodeCount {
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
}

#statusMessage {
  transition: opacity var(--transition-fast);
}

/* ============================
   KEYBOARD SHORTCUTS OVERLAY
============================ */
#shortcutsOverlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(26, 22, 20, 0.85);
  backdrop-filter: blur(8px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: overlayFadeIn 0.3s ease;
}

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

#shortcutsPanel {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  border: 1px solid #d4cfc7;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  width: 90%;
  max-width: 800px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: panelSlideIn 0.35s cubic-bezier(0.22, 0.9, 0.3, 1);
}

@keyframes panelSlideIn {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

#shortcutsHeader {
  padding: 24px 32px;
  border-bottom: 1px solid #d4cfc7;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(to bottom, #fdfcfb 0%, #f8f6f3 100%);
  border-radius: 16px 16px 0 0;
}

#shortcutsHeader h2 {
  font-family: 'Crimson Text', serif;
  font-size: 28px;
  font-weight: 600;
  color: #1a1614;
  margin: 0;
  letter-spacing: 0.5px;
}

#closeShortcutsBtn {
  background: none;
  border: none;
  font-size: 32px;
  color: #6b6560;
  cursor: pointer;
  padding: 0;
  width: 40px;
  height: 40px;
  line-height: 40px;
  border-radius: 8px;
  transition: all 0.2s;
  font-family: 'Courier New', monospace;
}

#closeShortcutsBtn:hover {
  background: #b8935f;
  color: #ffffff;
}

#shortcutsContent {
  padding: 32px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 32px;
}

#shortcutsContent::-webkit-scrollbar {
  width: 8px;
}

#shortcutsContent::-webkit-scrollbar-track {
  background: rgba(212, 207, 199, 0.2);
  border-radius: 4px;
}

#shortcutsContent::-webkit-scrollbar-thumb {
  background: rgba(184, 147, 95, 0.4);
  border-radius: 4px;
}

#shortcutsContent::-webkit-scrollbar-thumb:hover {
  background: rgba(184, 147, 95, 0.6);
}

.shortcuts-section {
  background: white;
  border: 1px solid #e8e5e0;
  border-radius: 12px;
  padding: 20px;
}

.shortcuts-section h3 {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  font-weight: 700;
  color: #b8935f;
  margin: 0 0 16px 0;
  letter-spacing: 1px;
  text-transform: uppercase;
  border-bottom: 2px solid #b8935f;
  padding-bottom: 8px;
}

.shortcut-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f0ebe5;
}

.shortcut-row:last-child {
  border-bottom: none;
}

.shortcut-action {
  font-family: 'Crimson Text', serif;
  font-size: 15px;
  color: #1a1614;
  font-weight: 500;
}

.shortcut-keys {
  display: flex;
  gap: 6px;
  align-items: center;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: #6b6560;
}

.shortcut-keys kbd {
  display: inline-block;
  padding: 4px 8px;
  background: linear-gradient(to bottom, #f8f6f3 0%, #e8e5e0 100%);
  border: 1px solid #d4cfc7;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  font-weight: 700;
  color: #1a1614;
  box-shadow: 
    0 2px 0 rgba(26, 22, 20, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  min-width: 24px;
  text-align: center;
}

/* Responsive: single column on smaller screens */
@media (max-width: 768px) {
  #shortcutsContent {
    grid-template-columns: 1fr;
  }
}

/* ============================
   EMPTY STATE
============================ */
#emptyState {
  transition: opacity 0.8s ease;
}

#emptyState.visible {
  opacity: 1 !important;
}

#emptyState text {
  animation: emptyStatePulse 3s ease-in-out infinite;
}

@keyframes emptyStatePulse {
  0%, 100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}

/* Dim arms when showing empty state */
body.empty-canvas .arm {
  opacity: 0.15;
  transition: opacity 0.8s ease;
}

body.empty-canvas .label {
  opacity: 0.15;
  transition: opacity 0.8s ease;
}

body.empty-canvas .center {
  opacity: 0.3;
  transition: opacity 0.8s ease;
}

/* Visual indicator for locked branches */
.arm.locked {
  opacity: 0.5;
  cursor: not-allowed !important;
}

.arm.locked:hover {
  stroke-width: 5 !important;
  filter: none !important;
}

#outlineMinimap {
  padding: 16px 24px;
  border-bottom: 1px solid #e8e5e0;
  background: linear-gradient(to bottom, #fdfcfb 0%, #f8f6f3 100%);
}

#outlineMinimap h4 {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  font-weight: 700;
  color: #6b6560;
  margin: 0 0 10px 0;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* Rotation handle animations */
.rotation-handle {
  animation: rotationHandlePulse 1.5s ease-in-out infinite;
}

@keyframes rotationHandlePulse {
  0%, 100% {
    opacity: 0.5;
  }
  50% {
    opacity: 0.8;
  }
}

/* ============================
   FOCUS MODE (when typing in nodes)
============================ */
body.focus-mode #toolbar,
body.focus-mode #statusBar,
body.focus-mode .edge-tab,
body.focus-mode #resetViewBtn,
body.focus-mode #addArmBtn {
  opacity: 0.3;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

body.focus-mode .arm:not(.selected):not(.typing) {
  opacity: 0.4;
}

body.focus-mode .label {
  opacity: 0.4;
}

body.focus-mode .arm.selected,
body.focus-mode .arm.typing {
  opacity: 1;
}

/* Scrollbar styling for panels */
#outlinePanelContent::-webkit-scrollbar,
#noteText::-webkit-scrollbar {
  width: 6px;
}

#outlinePanelContent::-webkit-scrollbar-track,
#noteText::-webkit-scrollbar-track {
  background: transparent;
}

#outlinePanelContent::-webkit-scrollbar-thumb,
#noteText::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 3px;
}

#outlinePanelContent::-webkit-scrollbar-thumb:hover,
#noteText::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* ============================
   TRAIL VIEW TOGGLE
============================ */
#trailViewContainer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 2px;
  flex-shrink: 0;
}

#trailViewLabel {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  user-select: none;
  cursor: pointer;
  transition: color var(--transition-fast);
}

#trailViewContainer:hover #trailViewLabel {
  color: var(--text-primary);
}

/* Toggle switch track */
.toggle-switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}
.toggle-track {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  border-radius: 11px;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.toggle-track::before {
  content: '';
  position: absolute;
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background: var(--bg-surface);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform var(--transition-fast);
}

/* Checked state */
.toggle-switch input:checked + .toggle-track {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle-switch input:checked + .toggle-track::before {
  transform: translateX(18px);
  background: var(--text-inverse);
}

/* Focus state */
.toggle-switch input:focus-visible + .toggle-track {
  outline: 2px solid var(--selection);
  outline-offset: 2px;
}

/* Hover state (when not checked) */
.toggle-switch:hover .toggle-track {
  border-color: var(--text-tertiary);
}

.toggle-switch input:checked + .toggle-track:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .outline-arm { transition: none !important; }
  .slide-panel { transition: none !important; }
  #notesPanel { transition: none !important; }
  #outlinePanel { transition: none !important; }
}


/* ============================
   CITATION MANAGEMENT
============================ */

/* Citation section in notes panel */
#citationList {
  /* no padding — parent handles it */
}

.cite-empty {
  color: var(--text-tertiary);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-style: italic;
  padding: 8px 0;
}

.cite-card {
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 2px;
  cursor: pointer;
  transition: background var(--transition-micro);
  position: relative;
}

.cite-card:hover {
  background: var(--bg-hover);
}

.cite-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.cite-detach-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), opacity var(--transition-fast);
  opacity: 0;
}

.cite-card:hover .cite-detach-btn {
  opacity: 1;
}

.cite-detach-btn:hover { color: #9F1239; }

.cite-type-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-family: 'Inter', sans-serif;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: white;
}

.cite-type-case { background: #991B1B; }
.cite-type-statute { background: #1E40AF; }
.cite-type-regulation { background: #7E22CE; }
.cite-type-secondary { background: #0F766E; }
.cite-type-record { background: #78350F; }

.cite-card-short {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.cite-card-full {
  font-family: 'IBM Plex Serif', serif;
  font-size: 12px;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.4;
}

.cite-card-pin {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.cite-card-pin::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-tertiary);
  margin-right: 6px;
  vertical-align: middle;
}

.cite-card-paren {
  font-family: 'IBM Plex Serif', serif;
  font-size: 11px;
  color: var(--text-tertiary);
  font-style: italic;
  margin-top: 2px;
}

/* Citation Form */
/* ============================
   CITATION FORM OVERLAY
============================ */

#citationFormOverlay {
  position: fixed;
  inset: 0;
  z-index: 9500;
  background: rgba(28, 25, 23, 0.4);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  animation: citationOverlayIn 200ms ease;
}

#citationFormOverlay[style*="display: flex"],
#citationFormOverlay.visible {
  display: flex;
}

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

#citationFormCard {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 420px;
  max-width: 90vw;
  animation: citationCardIn 240ms cubic-bezier(0.22, 0.9, 0.3, 1);
  overflow: hidden;
}

@keyframes citationCardIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

#citationFormHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

#citationFormTitle {
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

#citationFormHeader button {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
}

#citationFormHeader button:hover {
  color: var(--text-primary);
}

#citationFormBody {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cite-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  position: relative;
}

.cite-field label {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.cite-field select,
.cite-field input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-surface);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  box-sizing: border-box;
}

.cite-field select:focus,
.cite-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.08);
}

.cite-field input::placeholder {
  color: var(--text-tertiary);
}

.cite-field-row {
  display: flex;
  gap: 12px;
}

.cite-field-half {
  flex: 1;
}

#citationFormFooter {
  padding: 14px 24px 20px;
}

#citeSaveBtn {
  width: 100%;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--text-inverse);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast), transform 60ms ease;
}

#citeSaveBtn:hover { background: var(--brand-hover); }
#citeSaveBtn:active { transform: scale(0.985); }

#citeCancelBtn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color var(--transition-fast);
}

#citeCancelBtn:hover { color: var(--text-primary); }

/* Search results dropdown */
#citeSearchResults {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 5;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  margin-top: 4px;
}

#citeSearchResults:empty {
  display: none;
}

.cite-search-label {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.cite-search-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.cite-search-item:hover { background: var(--bg-hover); }

.cite-search-name {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--text-primary);
  font-weight: 500;
}

/* Citation Library Modal */
#citationLibraryModal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(28, 25, 23, 0.6);
  backdrop-filter: blur(4px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#citationLibraryContent {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: panelSlideIn 0.25s cubic-bezier(0.22, 0.9, 0.3, 1);
}

#citationLibraryHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-lg) var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

#citationLibraryHeader span {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 16px;
  color: var(--text-primary);
}

#closeCitationLibraryBtn {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 0;
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
}

#closeCitationLibraryBtn:hover { color: var(--text-primary); }

#citationLibrarySearch {
  padding: var(--space-sm) var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

#librarySearchInput {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-surface);
  outline: none;
  box-sizing: border-box;
  transition: border-color var(--transition-fast);
}

#librarySearchInput:focus { border-color: var(--accent); }
#librarySearchInput::placeholder { color: var(--text-tertiary); }

#citationLibraryList {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-sm) var(--space-lg);
}

#citationLibraryList::-webkit-scrollbar { width: 6px; }
#citationLibraryList::-webkit-scrollbar-track { background: transparent; }
#citationLibraryList::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 3px; }

.cite-library-empty {
  color: var(--text-tertiary);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  text-align: center;
  padding: 32px 0;
}

.cite-library-type-header {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-tertiary);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 12px 0 6px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 6px;
}

.cite-library-type-header:first-child { padding-top: 0; }

.cite-library-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
  margin-bottom: 2px;
}

.cite-library-item:hover { background: var(--bg-hover); }

.cite-library-item-main { flex: 1; min-width: 0; }

.cite-library-item-short {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.cite-library-item-full {
  font-family: 'IBM Plex Serif', serif;
  font-size: 12px;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cite-library-item-usage {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.cite-library-delete-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 16px;
  padding: 0;
  width: 24px; height: 24px;
  line-height: 24px;
  text-align: center;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: color var(--transition-fast);
}

.cite-library-delete-btn:hover { color: #9F1239; }

#citationLibraryFooter {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) var(--space-lg);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

#copyToABtn {
  padding: 7px 14px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

#copyToABtn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}

#citationLibraryCount {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: var(--text-tertiary);
}

/* Citation count in outline */
.outline-cite-count {
  display: inline-block;
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  border-radius: 3px;
  padding: 0 5px;
  font-size: 9px;
  font-weight: 600;
  color: var(--text-tertiary);
  margin-left: 6px;
  vertical-align: middle;
}

/* ============================
   EXPORT SYSTEM
============================ */

#exportDropdown .dropdown-menu {
  left: auto;
  right: 0;
  min-width: 240px;
}

#exportDropdown .dropdown-item strong {
  font-size: 13px;
}

#exportDropdown .dropdown-item span {
  font-size: 11px;
  color: var(--text-secondary);
}

#exportDropdown .dropdown-item:hover strong {
  color: var(--accent);
}

/* ============================
   CLOUD PROJECT SWITCHER
============================ */
#cloudProjectMenu {
  min-width: 280px;
  max-height: 400px;
  display: flex;
  flex-direction: column;
}

#cloudProjectMenuHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

#cloudProjectMenuHeader span {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#cloudNewProjectBtn {
  background: none;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

#cloudNewProjectBtn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}

#cloudProjectList {
  overflow-y: auto;
  max-height: 300px;
  padding: var(--space-xs) 0;
}

#cloudProjectList::-webkit-scrollbar { width: 6px; }
#cloudProjectList::-webkit-scrollbar-track { background: transparent; }
#cloudProjectList::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 3px; }

.cloud-project-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px var(--space-md);
  cursor: pointer;
  transition: background var(--transition-fast);
  border-bottom: 1px solid var(--border-subtle);
}

.cloud-project-item:last-child { border-bottom: none; }
.cloud-project-item:hover { background: var(--bg-hover); }
.cloud-project-item.active { background: var(--selection-subtle); }

.cloud-project-info { flex: 1; min-width: 0; }

.cloud-project-name {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cloud-project-date {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.cloud-project-delete {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 16px;
  padding: 0;
  width: 24px; height: 24px;
  line-height: 24px;
  text-align: center;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--transition-fast), color var(--transition-fast);
}

.cloud-project-item:hover .cloud-project-delete { opacity: 1; }
.cloud-project-delete:hover { color: #9F1239; }

.cloud-project-empty {
  padding: 20px var(--space-md);
  text-align: center;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ============================
   TOOLBAR CLEANUP
============================ */
.toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border-default);
  margin: 0 4px;
  flex-shrink: 0;
}

/* ============================
   PROJECT NAME (TOOLBAR)
============================ */
#projectNameContainer {
  display: flex;
  align-items: center;
  min-width: 0;
  flex-shrink: 1;
  max-width: 220px;
}

#projectNameDisplay {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: text;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  border: 1px solid transparent;
  line-height: 1.3;
  user-select: none;
}

#projectNameDisplay:hover {
  background: var(--bg-hover);
  border-color: var(--border-default);
}

#projectNameInput {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  padding: 5px 10px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  outline: none;
  width: 200px;
  max-width: 220px;
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
  display: none;
  line-height: 1.3;
}

#projectNameInput::placeholder {
  color: var(--text-tertiary);
  font-weight: 400;
}
/* More dropdown */
#moreMenu {
  min-width: 200px;
  right: 0;
  left: auto;
}

.dropdown-action {
  padding: 10px var(--space-md);
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  transition: background var(--transition-fast);
}

.dropdown-action:hover {
  background: var(--bg-hover);
}

.dropdown-action-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 4px 0;
}

/* Project rename */
#cloudProjectRename {
  padding: 10px var(--space-md);
  border-top: 1px solid var(--border-subtle);
}

#cloudRenameInput {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-surface);
  outline: none;
  box-sizing: border-box;
  margin-bottom: 8px;
  transition: border-color var(--transition-fast);
}

#cloudRenameInput:focus { border-color: var(--accent); }

.cloud-rename-actions {
  display: flex;
  gap: 6px;
}

.cloud-rename-actions button {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border-default);
  transition: all var(--transition-fast);
}

#cloudRenameSave {
  background: var(--accent);
  color: var(--text-inverse);
  border-color: var(--accent);
}

#cloudRenameSave:hover { background: var(--accent-hover); }

#cloudRenameCancel {
  background: var(--bg-surface);
  color: var(--text-secondary);
}

#cloudRenameCancel:hover { background: var(--bg-hover); }

/* Cloud project item rename button */
.cloud-project-rename {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--transition-fast), color var(--transition-fast);
  font-family: 'Inter', sans-serif;
}

.cloud-project-item:hover .cloud-project-rename { opacity: 1; }
.cloud-project-rename:hover { color: var(--accent); }

/* Remove old toolbar max-width override if it exists */

/* ============================
   TOOLBAR EXPAND/COLLAPSE
============================ */

#historyBtn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px !important;
  min-width: 32px;
}

#historyBtn svg {
  flex-shrink: 0;
}

#toolbarExpandBtn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 6px !important;
  min-width: 24px;
  flex-shrink: 0;
}

.expand-dots {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: center;
}

.expand-dots i {
  display: block;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-tertiary);
  font-style: normal;
  transition: background var(--transition-fast);
}

#toolbarExpandBtn:hover .expand-dots i {
  background: var(--text-primary);
}

#toolbarExpandBtn.active .expand-dots i {
  background: var(--accent);
}

#toolbarExpandable {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-width 300ms cubic-bezier(0.22, 0.9, 0.3, 1),
              opacity 200ms ease-out;
}

#toolbarExpandable.expanded {
  max-width: 480px;
  opacity: 1;
  transition: max-width 300ms cubic-bezier(0.22, 0.9, 0.3, 1),
              opacity 250ms 50ms ease-out;
}

/* ============================
   BRAND IDENTITY
============================ */

#appVersion {
  font-weight: 400;
  color: rgba(255, 255, 255, 0.3);
  font-size: 10px;
  letter-spacing: 0.02em;
}

/* ============================
   PROJECT CONTEXT MENU
============================ */
#projectContextMenu {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 4px 0;
  min-width: 120px;
}

#projectContextMenu .menu-item {
  padding: 8px 16px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  transition: background var(--transition-micro);
}

#projectContextMenu .menu-item:hover {
  background: var(--bg-hover);
}

#deleteProjectOption:hover {
  background: rgba(159, 18, 57, 0.08);
  color: #9F1239;
}

/* Inline rename input inside project list */
.cloud-rename-inline {
  width: 100%;
  padding: 4px 8px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-surface);
  outline: none;
  box-sizing: border-box;
  box-shadow: 0 0 0 3px rgba(71, 85, 105, 0.15);
}

.cloud-rename-inline:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(71, 85, 105, 0.25);
}

.cloud-rename-inline::placeholder {
  color: var(--text-tertiary);
  font-weight: 400;
}

/* ============================
   PROJECT GALLERY VIEW
============================ */
#galleryView {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  background: var(--bg-canvas);
  overflow-y: auto;
  overflow-x: hidden;
}

/* Hide canvas and all canvas-related UI completely when gallery is open */
body.gallery-open #whirlybird,
body.gallery-open #toolbar,
body.gallery-open #subToolbarRow,
body.gallery-open #statusBar,
body.gallery-open #addArmBtn,
body.gallery-open .edge-tab {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  z-index: -1 !important;
}



/* Gallery Header */
#galleryHeader {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(250, 250, 249, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-default);
  padding: 0 48px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#galleryHeaderLeft {
  display: flex;
  align-items: center;
}

#galleryLogo {
  font-family: 'Playfair Display', serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.02em;
  user-select: none;
}

.gallery-logo-mark {
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: var(--text-inverse);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#galleryHeaderRight {
  display: flex;
  align-items: center;
  gap: 12px;
}

#gallerySearch {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 7px 12px;
  transition: border-color var(--transition-fast);
}

#gallerySearch:focus-within {
  border-color: var(--accent);
}

#gallerySearch svg {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

#gallerySearchInput {
  border: none;
  outline: none;
  background: transparent;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--text-primary);
  width: 200px;
}

#gallerySearchInput::placeholder {
  color: var(--text-tertiary);
}

#gallerySortSelect {
  padding: 7px 12px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-fast);
  -webkit-appearance: none;
  appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23A8A29E' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

#gallerySortSelect:focus {
  border-color: var(--accent);
}

/* Gallery Body */
#galleryBody {
  max-width: 1120px;
  margin: 0 auto;
  padding: 40px 48px;
}

#galleryTitleRow {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 32px;
}

#galleryTitle {
  font-family: 'Playfair Display', serif;
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin: 0;
}

#galleryCount {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text-tertiary);
  font-weight: 400;
}

/* Gallery Grid */
#galleryGrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

@media (max-width: 900px) {
  #galleryGrid { grid-template-columns: repeat(2, 1fr); }
  #galleryBody { padding: 32px 24px; }
  #galleryHeader { padding: 0 24px; }
}

@media (max-width: 580px) {
  #galleryGrid { grid-template-columns: 1fr; }
}
/* ---------- Landing gallery (refined, modern) ---------- */
#galleryBody {
  max-width: 1200px;
  margin: 0 auto;
  padding: 56px 48px;
  color: var(--text-secondary);
}

/* Top title row */
#galleryTitleRow {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 28px;
  justify-content: space-between;
}

/* Prominent page title */
#galleryTitle {
  font-family: 'Playfair Display', serif;
  font-size: 38px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin: 0;
}

/* subtle count */
#galleryCount {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text-tertiary);
  font-weight: 500;
  align-self: center;
  margin-left: 6px;
}

/* Grid layout - responsive and generous spacing */
#galleryGrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
  margin-top: 12px;
}

@media (max-width: 1000px) {
  #galleryGrid { grid-template-columns: repeat(2, 1fr); gap: 20px; padding: 0 12px; }
  #galleryBody { padding: 44px 24px; }
}
@media (max-width: 600px) {
  #galleryGrid { grid-template-columns: 1fr; gap: 16px; }
  #galleryBody { padding: 28px 16px; }
}

/* Project card - clean, elevated, restrained */
.gallery-card {
  will-change: transform, box-shadow;
  background: linear-gradient(180deg, var(--bg-surface) 0%, #FBFBFB 100%);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: transform 200ms cubic-bezier(0.22, 0.9, 0.3, 1), box-shadow 200ms cubic-bezier(0.22, 0.9, 0.3, 1), border-color 200ms ease;
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* subtle hover elevation (not cartoonish) */
.gallery-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: rgba(17,24,39,0.06);
}

/* Card preview area (visual thumbnail) */
.gallery-card-preview {
  aspect-ratio: 4 / 3;
  min-height: 180px;
  background-color: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 28px;
  flex: 0 0 auto;
}

/* keep scaled SVG small and crisp */
.gallery-card-preview svg {
  max-width: 88%;
  max-height: 88%;
  transition: transform var(--transition-fast);
}

/* subtle focus on hover */
.gallery-card:hover .gallery-card-preview svg {
  transform: translateY(-4px) scale(1.02);
}

/* Sample project card */
.gallery-card-sample {
  position: relative;
  border-style: solid;
  border-color: var(--border-subtle);
  background: linear-gradient(180deg, var(--bg-subtle) 0%, #FFFFFF 100%);
}

.gallery-card-sample::before {
  content: 'Sample';
  position: absolute;
  top: 10px;
  left: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(30, 58, 95, 0.06);
  color: var(--brand, #1E3A5F);
}

.gallery-card-sample .gallery-card-meta span.sample-note {
  color: var(--text-tertiary);
}

.gallery-card-sample .gallery-card-meta span.sample-pill {
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(30, 58, 95, 0.04);
  font-size: 11px;
}

/* Info row at bottom */
.gallery-card-info {
  padding: 18px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  background: transparent;
}

/* Text block */
.gallery-card-text { flex: 1; min-width: 0; }

/* Project name (single-line, strong) */
.gallery-card-name {
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

/* meta row beneath name */
.gallery-card-meta {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

/* New project card (dashed, subtle) */
.gallery-card.new {
  border-style: dashed;
  border-color: var(--border-subtle);
  background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-surface) 100%);
  display: grid;
  place-items: center;
  min-height: 220px;
}

.gallery-card.new .gallery-card-preview { padding: 16px; }

/* subtle badges / now playing */
.gallery-badge {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--brand-subtle);
  color: var(--brand);
  border: 1px solid rgba(17,24,39,0.03);
  white-space: nowrap;
}


.gallery-card-meta .meta-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--border-default);
}

/* Template pill badge under project name */
.gallery-card-template-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 100px;
  background: var(--accent-subtle);
  color: var(--accent);
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0;
}

.gallery-card-menu {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: opacity var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-card:hover .gallery-card-menu {
  opacity: 1;
}

.gallery-card-menu:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* New Project Card */
.gallery-card-new {
  border-style: dashed;
  border-color: var(--border-default);
  background: transparent;
}

.gallery-card-new:hover {
  border-color: var(--accent);
  background: var(--accentSoft, rgba(30, 58, 95, 0.04));
}

.gallery-card-new .gallery-card-preview {
  background: transparent;
  flex-direction: column;
  gap: 12px;
}

.gallery-card-new-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 200ms ease, background 200ms ease;
}

.gallery-card-new:hover .gallery-card-new-icon {
  border-color: var(--accent);
  background: rgba(30, 58, 95, 0.06);
}

.gallery-card-new-icon svg {
  transition: none;
}

.gallery-card-new-label {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-tertiary);
  transition: color 200ms ease;
}

.gallery-card-new:hover .gallery-card-new-label {
  color: var(--accent);
}

/* Gallery Card Context Menu */
.gallery-card-context {
  position: fixed;
  z-index: 10002;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 4px 0;
  min-width: 140px;
  display: none;
}

.gallery-card-context .menu-item {
  padding: 8px 16px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  transition: background var(--transition-micro);
}

.gallery-card-context .menu-item:hover {
  background: var(--bg-hover);
}

.gallery-card-context .menu-item.danger:hover {
  background: rgba(159, 18, 57, 0.08);
  color: #9F1239;
}

/* Gallery helper bar (when Examples + Tutorial rows are collapsed) */
#galleryHelperBar {
  display: none !important;
}

.gallery-helper-links {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--text-tertiary);
}

.gallery-helper-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--accent, #1E3A5F);
  cursor: pointer;
  text-decoration: none;
  transition: color var(--transition-fast);
}

.gallery-helper-link:hover {
  text-decoration: underline;
  color: var(--text-primary);
}

.gallery-helper-sep {
  color: var(--border-default);
  user-select: none;
}

/* Shared helper row (Examples + Getting Started) */
.gallery-helper-row {
  margin: 0 0 32px;
  padding: 0;
  transition: margin-bottom 400ms cubic-bezier(0.22, 0.9, 0.3, 1);
}

/* Extra space above Examples + Getting Started so they don’t rub on the grid */
#galleryExamplesSection {
  margin-top: 48px;
}

.gallery-helper-row.collapsed {
  margin-bottom: 0;
}

.gallery-helper-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 16px;
}

.gallery-helper-row-title {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Examples row — horizontal scroll strip */
#galleryExamplesSection .gallery-helper-row-header {
  margin-bottom: 12px;
  transition: margin-bottom 400ms cubic-bezier(0.22, 0.9, 0.3, 1);
}

#galleryExamplesSection.collapsed .gallery-helper-row-header {
  margin-bottom: 0;
}

#galleryExamplesStrip {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0 12px;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
  max-height: 320px;
  opacity: 1;
  transition: max-height 400ms cubic-bezier(0.22, 0.9, 0.3, 1),
              opacity 300ms ease,
              padding 400ms cubic-bezier(0.22, 0.9, 0.3, 1);
}

#galleryExamplesStrip::-webkit-scrollbar {
  height: 6px;
}

#galleryExamplesStrip::-webkit-scrollbar-track {
  background: var(--bg-subtle);
  border-radius: 3px;
}

#galleryExamplesStrip::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 3px;
}

/* Example cards in strip — lighter/smaller than main grid cards */
#galleryExamplesStrip .gallery-card-sample {
  flex: 0 0 auto;
  width: 280px;
  min-height: 0;
  border-color: var(--border-subtle);
  background: linear-gradient(180deg, var(--bg-subtle) 0%, #FAFAFA 100%);
  opacity: 0.95;
}

#galleryExamplesStrip .gallery-card-sample:hover {
  opacity: 1;
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

#galleryExamplesStrip .gallery-card-preview {
  aspect-ratio: 4 / 3;
  min-height: 160px;
  padding: 20px;
}

#galleryExamplesStrip .gallery-card-preview svg {
  max-width: 85%;
  max-height: 85%;
}

#galleryExamplesStrip .gallery-card-info {
  padding: 12px 14px;
}

#galleryExamplesStrip .gallery-card-name {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

#galleryExamplesStrip .gallery-card-meta {
  font-size: 11px;
}

#galleryExamplesStrip .gallery-card-sample::before {
  font-size: 9px;
  padding: 3px 6px;
  top: 8px;
  left: 8px;
}

#galleryExamplesStrip .gallery-card-sample .sample-note {
  display: none;
}

/* Examples row collapsed state */
#galleryExamplesSection.collapsed #galleryExamplesStrip {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
}

#galleryExamplesToggleBtn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), transform var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

#galleryExamplesToggleBtn:hover {
  color: var(--text-primary);
}

#galleryExamplesToggleBtn.collapsed {
  transform: rotate(-90deg);
}

#galleryExamplesSection.gallery-examples-empty {
  display: none;
}

/* Tutorial Section (shared helper row styles) */
#galleryTutorial {
  padding-bottom: 48px;
  margin-top: 28px;
  transition: padding-bottom 400ms cubic-bezier(0.22, 0.9, 0.3, 1);
}

#galleryTutorial.collapsed {
  padding-bottom: 0;
}

#tutorialHeader {
  margin-bottom: 24px;
  transition: margin-bottom 400ms cubic-bezier(0.22, 0.9, 0.3, 1);
}

#galleryTutorial.collapsed #tutorialHeader {
  margin-bottom: 0;
}

#tutorialHeader.gallery-helper-row-header {
  padding-bottom: 20px;
  margin-bottom: 24px;
}

#tutorialToggleBtn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), transform var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

#tutorialToggleBtn:hover {
  color: var(--text-primary);
}

#tutorialToggleBtn.collapsed {
  transform: rotate(-90deg);
}

#tutorialSteps {
  display: flex;
  gap: 16px;
  overflow: hidden;
  max-height: 500px;
  opacity: 1;
  transition: max-height 400ms cubic-bezier(0.22, 0.9, 0.3, 1),
              opacity 300ms ease;
}

#galleryTutorial.collapsed #tutorialSteps {
  max-height: 0;
  opacity: 0;
}

.tutorial-step {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  padding: 20px 16px;
  text-align: center;
  position: relative;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.tutorial-step:hover {
  border-color: var(--text-tertiary);
  box-shadow: var(--shadow-sm);
}

.tutorial-step-num {
  position: absolute;
  top: 10px;
  left: 12px;
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-tertiary);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tutorial-step-icon {
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 48px;
}

.tutorial-step-title {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.tutorial-step-desc {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

@media (max-width: 900px) {
  #tutorialSteps { flex-wrap: wrap; }
  .tutorial-step { flex: 1 1 calc(50% - 8px); min-width: 180px; }
  #galleryTutorial { padding-bottom: 48px; }
}

@media (max-width: 580px) {
  .tutorial-step { flex: 1 1 100%; }
}

/* Gallery Show More / Collapse */
.gallery-grid-collapsed .gallery-card:nth-child(n+7) {
  display: none;
}

#galleryShowMoreWrap {
  display: flex;
  justify-content: center;
  padding: 28px 0 0;
}

#galleryShowMoreBtn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border: 1px solid var(--border-default);
  border-radius: 100px;
  background: var(--bg-surface);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

#galleryShowMoreBtn:hover {
  color: var(--text-primary);
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

#galleryShowMoreBtn:active {
  transform: scale(0.985);
  box-shadow: var(--shadow-sm);
}

#galleryShowMoreIcon {
  transition: transform 300ms cubic-bezier(0.22, 0.9, 0.3, 1);
  flex-shrink: 0;
}

/* Cross-link system */
.cross-link-path {
  transition: opacity 140ms ease;
}

#whirlybird.linking-mode {
  cursor: crosshair !important;
}

#whirlybird.linking-mode .arm-hitbox {
  cursor: crosshair !important;
}

#whirlybird.linking-mode .arm {
  opacity: 0.5;
}

#whirlybird.linking-mode .arm.selected {
  opacity: 1;
}

/* Cross-link section in notes panel */
/* ============================
   UNIFIED REFERENCES SECTION
============================ */

#referencesSection {
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  max-height: 50%;
  transition: max-height 280ms cubic-bezier(0.22, 0.9, 0.3, 1);
}

#referencesSection.collapsed {
  max-height: 40px;
}

#referencesHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px var(--space-lg);
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
  transition: background var(--transition-fast);
}

#referencesHeader:hover {
  background: var(--bg-hover);
}

#referencesHeaderLeft {
  display: flex;
  align-items: center;
  gap: 8px;
}

.references-title {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.references-count-badge {
  padding: 1px 6px;
  border-radius: 100px;
  background: var(--bg-subtle);
  color: var(--text-tertiary);
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.4;
}

#referencesToggleBtn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast), transform 280ms cubic-bezier(0.22, 0.9, 0.3, 1);
}

#referencesToggleBtn:hover {
  color: var(--text-primary);
}

#referencesSection.collapsed #referencesToggleBtn {
  transform: rotate(-90deg);
}

#referencesBody {
  overflow-y: auto;
  padding: 0 var(--space-lg) var(--space-sm);
  opacity: 1;
  transition: opacity 200ms ease;
}

#referencesSection.collapsed #referencesBody {
  display: none;
}

#referencesBody::-webkit-scrollbar { width: 4px; }
#referencesBody::-webkit-scrollbar-track { background: transparent; }
#referencesBody::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 2px; }

#referencesDivider {
  height: 1px;
  background: var(--border-subtle);
  margin: 6px 0;
}

#referencesDivider:only-child,
#crossLinkList:empty + #referencesDivider,
#referencesDivider + #citationList:empty {
  display: none;
}

#crossLinkList {
  /* no padding — parent handles it */
}

#referencesActions {
  display: flex;
  gap: 8px;
  padding: 10px 0 4px;
}

.ref-action-btn {
  flex: 1;
  padding: 7px 12px;
  border: 1px dashed var(--border-default);
  border-radius: 100px;
  background: transparent;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  text-align: center;
  transition: all var(--transition-fast);
}

.ref-action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(30, 58, 95, 0.03);
  border-style: solid;
}

.cross-link-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  margin-bottom: 4px;
}

.cross-link-item:hover {
  background: var(--bg-hover);
  border-color: var(--border-default);
}

.cross-link-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.cross-link-item-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 8px;
}

.cross-link-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cross-link-dir {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: var(--text-tertiary);
  flex-shrink: 0;
  font-weight: 500;
}

.cross-link-label {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.cross-link-type-badge {
  font-family: 'Inter', sans-serif;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid;
  white-space: nowrap;
  opacity: 0.7;
}

.cross-link-item:hover .cross-link-type-badge {
  opacity: 1;
}

.cross-link-delete {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--transition-fast), color var(--transition-fast);
}

.cross-link-item:hover .cross-link-delete {
  opacity: 1;
}

.cross-link-delete:hover {
  color: #9F1239;
}

/* Gallery Show More / Collapse */
.gallery-grid-collapsed .gallery-card:nth-child(n+7) {
  display: none;
}

#galleryShowMoreWrap {
  display: flex;
  justify-content: center;
  padding: 28px 0 0;
}

#galleryShowMoreBtn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border: 1px solid var(--border-default);
  border-radius: 100px;
  background: var(--bg-surface);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

#galleryShowMoreBtn:hover {
  color: var(--text-primary);
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

#galleryShowMoreBtn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

#galleryShowMoreIcon {
  transition: transform 300ms cubic-bezier(0.22, 0.9, 0.3, 1);
  flex-shrink: 0;
}

/* Empty state for gallery */.gallery-empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 24px;
  color: var(--text-tertiary);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
}

/* Update toolbar logo to be clickable button */
#toolbarLogo {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--accent);
  transition: color var(--transition-fast), background var(--transition-fast);
}

#toolbarLogo:hover {
  color: var(--accent-hover);
  background: var(--bg-hover);
}

#toolbarLogo .whirly-logo {
  display: block;
  transition: transform 0.1s ease;
}

#toolbarLogo.spinning .whirly-logo {
  animation: logoSpin 600ms cubic-bezier(0.22, 0.9, 0.3, 1) forwards;
}

@keyframes logoSpin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
/* ============================
   GALLERY CARD ANIMATIONS
============================ */

#galleryGrid {
  transition: none;
}

/* ============================
   GALLERY ↔ CANVAS TRANSITIONS
============================ */
#galleryTransitionOverlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 8500;
  pointer-events: none;
  overflow: hidden;
}

.transition-card {
  position: absolute;
  background: var(--bg-surface);
  border-radius: 12px;
  border: 1px solid var(--border-default);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  will-change: transform, width, height, top, left, border-radius, opacity;
}

.transition-card .transition-preview {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    var(--bg-canvas)
    url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M 40 0 L 0 0 0 40' fill='none' stroke='%23e8e6e1' stroke-width='0.5'/%3E%3C/svg%3E");
}

.transition-card .transition-info {
  padding: 14px 16px;
  border-top: 1px solid var(--border-subtle);
}

.transition-card .transition-name {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Hide toolbar and status bar during transitions */
body.transitioning #toolbar,
body.transitioning #statusBar,
body.transitioning #addArmBtn,
body.transitioning .edge-tab,
body.transitioning #breadcrumbTrail {
  opacity: 0 !important;
  transition: opacity 150ms ease;
}

body.transitioning #whirlybird {
  opacity: 0;
}

/* Gallery fade underneath during card expand */
#galleryView.transition-fade {
  transition: opacity 250ms ease;
  opacity: 0;
}

/* ===== Cursor rules for arms vs labels =====
   - Hand (pointer) when hovering the arm path/hitbox
   - Text (caret) when hovering label text (textPath/tspan)
   This is intentionally specific so other UI cursors are unaffected.
*/

 /* pointer for visible root arms and dynamic arm paths/hitboxes */
use.arm,
path.arm,
.path-arm {
  pointer-events: none !important;
}

.arm-hitbox {
  cursor: pointer;
}

/* ensure SVG text labels keep caret/text cursor */
svg text,
svg textPath,
svg tspan,
svg .label-text,
svg .arm-label {
  cursor: pointer !important;
}

/* Safety: if a label element is on top of the hitbox, the caret will show */
/* but if the user is over the path/hitbox area itself the pointer shows. */
/* ============================
   GALLERY MULTI-SELECT
============================ */

/* Selected card */
.gallery-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent), var(--shadow-md);
}

.gallery-card.selected .gallery-card-preview {
  background-color: rgba(30, 58, 95, 0.03);
}

/* Checkmark badge */
.gallery-card.selected::after {
  content: '';
  position: absolute;
  top: 12px;
  right: 12px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  z-index: 5;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 180ms ease, transform 180ms cubic-bezier(0.22, 0.9, 0.3, 1);
}

.gallery-card.selected::after {
  opacity: 1;
  transform: scale(1);
}

/* Active project card (current workspace) */
.gallery-card.active {
  background: linear-gradient(180deg, rgba(30,58,95,0.02) 0%, var(--bg-surface) 100%);
}

/* Dim non-selected cards when there IS a selection */
#galleryGrid.has-selection .gallery-card:not(.selected):not(.gallery-card-new) {
  opacity: 0.55;
  transition: opacity 200ms ease;
}

#galleryGrid.has-selection .gallery-card:not(.selected):not(.gallery-card-new):hover {
  opacity: 0.85;
}

/* Lasso rectangle */
#galleryLasso {
  position: fixed;
  border: 1.5px solid var(--accent);
  background: rgba(30, 58, 95, 0.06);
  border-radius: 3px;
  pointer-events: none;
  z-index: 9000;
  display: none;
}

/* Selection action bar */
#galleryActionBar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: var(--text-primary);
  color: var(--text-inverse);
  border-radius: 100px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  z-index: 8500;
  opacity: 0;
  pointer-events: none;
  transition: transform 360ms cubic-bezier(0.22, 0.9, 0.3, 1),
              opacity 280ms ease;
  user-select: none;
}

#galleryActionBar.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: all;
}

#galleryActionBar .action-bar-count {
  color: rgba(255, 255, 255, 0.7);
}

#galleryActionBar .action-bar-divider {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.15);
}

#galleryActionBar button {
  background: none;
  border: none;
  color: var(--text-inverse);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 14px;
  border-radius: 100px;
  transition: background 140ms ease;
}

#galleryActionBar button:hover {
  background: rgba(255, 255, 255, 0.12);
}

#galleryActionBar .action-bar-delete {
  color: #fca5a5;
}

#galleryActionBar .action-bar-delete:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #fecaca;
}

#galleryActionBar .action-bar-clear {
  color: rgba(255, 255, 255, 0.5);
}

/* ============================
   PLACEHOLDER LABELS (template hints)
============================ */

.placeholder-label {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-style: normal;
  fill: var(--text-tertiary);
  opacity: 0.55;
  user-select: none;
  pointer-events: none;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-anchor: middle;
  transition: opacity 260ms ease;
}

.placeholder-label.placeholder-tag {
  opacity: 0.4;
}

/* ============================
   CROSS-LINK DASH FLOW ANIMATION
============================ */

@keyframes dashFlow {
  from {
    stroke-dashoffset: 0;
  }
  to {
    stroke-dashoffset: -24;
  }
}

@keyframes dashFlowSupports {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: -24; }
}

@keyframes dashFlowUndermines {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: -36; }
}

@keyframes dashFlowRelates {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: -16; }
}

.cross-link-path.flowing-supports {
  animation: dashFlowSupports 0.6s linear infinite;
  stroke-dasharray: 8, 4 !important;
}

.cross-link-path.flowing-undermines {
  animation: dashFlowUndermines 0.8s linear infinite;
  stroke-dasharray: 12, 6 !important;
}

.cross-link-path.flowing-relates {
  animation: dashFlowRelates 0.5s linear infinite;
  stroke-dasharray: 4, 4 !important;
}

/* ============================
   OUTLINE CROSS-REFERENCES
============================ */

.outline-xref {
  display: block;
  padding: 3px 12px 3px 28px;
  font-family: 'IBM Plex Serif', Georgia, serif;
  font-size: 11px;
  font-style: italic;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
  line-height: 1.5;
  position: relative;
}

.outline-xref:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.outline-xref::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
  flex-shrink: 0;
}

.outline-xref[data-link-type="supports"]::before {
  background: #166534;
}

.outline-xref[data-link-type="undermines"]::before {
  background: #991B1B;
}

.outline-xref[data-link-type="relates"]::before {
  background: #475569;
}

.outline-xref-signal {
  font-style: italic;
  font-weight: 500;
  color: var(--text-secondary);
}

.outline-xref-target {
  font-style: normal;
  font-weight: 500;
}

.outline-xref-direction {
  font-style: italic;
}

.outline-xref-role {
  font-style: normal;
  font-size: 9px;
  font-family: 'Inter', sans-serif;
  color: var(--text-tertiary);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-left: 4px;
  opacity: 0.7;
}

/* ============================
   PAGE SWITCHER — MODERN DROPDOWN
============================ */



#pageSwitcherBtn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 100px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(16, 20, 24, 0.04);
  white-space: nowrap;
  transition: box-shadow 250ms ease,
              border-color 250ms ease,
              transform 360ms cubic-bezier(0.22, 0.9, 0.3, 1);
}

#pageSwitcherBtn:hover {
  border-color: var(--text-tertiary);
  box-shadow: 0 4px 14px rgba(16, 20, 24, 0.07);
}

#pageSwitcherBtn.open {
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(16, 20, 24, 0.07);
}

#pageSwitcherIcon {
  display: flex;
  align-items: center;
  color: var(--text-tertiary);
  transition: color var(--transition-fast);
}

#pageSwitcherBtn:hover #pageSwitcherIcon,
#pageSwitcherBtn.open #pageSwitcherIcon {
  color: var(--accent);
}

#pageSwitcherName {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-count-badge {
  padding: 1px 6px;
  border-radius: 100px;
  background: var(--bg-subtle);
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.4;
}

#pageSwitcherChevron {
  color: var(--text-tertiary);
  transition: transform 200ms cubic-bezier(0.22, 0.9, 0.3, 1), color var(--transition-fast);
  flex-shrink: 0;
}

#pageSwitcherBtn.open #pageSwitcherChevron {
  transform: rotate(180deg);
  color: var(--accent);
}

/* Dropdown panel */
#pageSwitcherDropdown {
  position: fixed;
  display: none;
  z-index: 10000;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 40px rgba(16, 20, 24, 0.12), 0 0 0 1px rgba(16, 20, 24, 0.02);
  width: 300px;
  max-height: 420px;
  display: none;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 180ms ease, transform 180ms cubic-bezier(0.22, 0.9, 0.3, 1);
}

#pageSwitcherDropdown.open {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

/* Search */
#pageSwitcherSearch {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

#pageSwitcherSearch svg {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

#pageSearchInput {
  border: none;
  outline: none;
  background: transparent;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-primary);
  width: 100%;
}

#pageSearchInput::placeholder {
  color: var(--text-tertiary);
}

/* Page list */
#pageSwitcherList {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  scroll-behavior: smooth;
}

#pageSwitcherList::-webkit-scrollbar { width: 4px; }
#pageSwitcherList::-webkit-scrollbar-track { background: transparent; }
#pageSwitcherList::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 2px; }

.page-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-micro);
  position: relative;
}

.page-list-item:hover {
  background: var(--bg-hover);
}

.page-list-item.active {
  background: var(--accent-subtle);
}

.page-list-item-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--border-default);
  transition: background var(--transition-fast);
}

.page-list-item.active .page-list-item-indicator {
  background: var(--accent);
}

.page-list-item-content {
  flex: 1;
  min-width: 0;
}

.page-list-item-name {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.page-list-item.active .page-list-item-name {
  font-weight: 600;
  color: var(--accent);
}

.page-list-item-template {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.page-list-item-nodes {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  color: var(--text-tertiary);
  white-space: nowrap;
  flex-shrink: 0;
}

.page-list-item-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--transition-fast);
  flex-shrink: 0;
}

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

.page-list-item-actions button {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 14px;
  line-height: 1;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.page-list-item-actions button:hover {
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.04);
}

.page-list-item-actions .page-delete-btn:hover {
  color: #9F1239;
  background: rgba(159, 18, 57, 0.06);
}

/* Drag reorder visual */
.page-list-item.dragging {
  opacity: 0.4;
}

.page-list-item.drag-over {
  box-shadow: inset 0 2px 0 0 var(--accent);
}

/* Footer */
#pageSwitcherFooter {
  padding: 8px 10px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

#addPageBtn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

#addPageBtn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(30, 58, 95, 0.03);
}

#addPageBtn svg {
  color: var(--text-tertiary);
  transition: color var(--transition-fast);
}

#addPageBtn:hover svg {
  color: var(--accent);
}

/* Empty state */
.page-list-empty {
  padding: 20px 14px;
  text-align: center;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--text-tertiary);
}

/* Add page template menu */
#addPageTemplateMenu {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 40px rgba(16, 20, 24, 0.12);
  padding: 4px 0;
  min-width: 240px;
  overflow: hidden;
}

.add-page-template-header {
  padding: 8px 14px 6px;
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.add-page-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background var(--transition-micro);
}

.add-page-item:hover {
  background: var(--bg-hover);
}

.add-page-item-name {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.add-page-item-meta {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 400;
}

/* Inline rename within dropdown – subtle so it doesn’t cover the template line below */
.page-rename-inline {
  border: 1px solid var(--border-default);
  border-radius: 4px;
  padding: 2px 6px;
  margin-bottom: 2px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-surface);
  outline: none;
  width: 100%;
  box-sizing: border-box;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.page-rename-inline:hover {
  border-color: rgba(0, 0, 0, 0.12);
}

.page-rename-inline:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(30, 58, 95, 0.08);
}

.page-rename-inline::placeholder {
  color: var(--text-tertiary);
  font-weight: 400;
}
/* Page context menu */
#pageTabContextMenu {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 4px 0;
  min-width: 130px;
}

#pageTabContextMenu .menu-item {
  padding: 8px 16px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  transition: background var(--transition-micro);
}

#pageTabContextMenu .menu-item:hover {
  background: var(--bg-hover);
}

#deletePageOption:hover {
  background: rgba(159, 18, 57, 0.08);
  color: #9F1239;
}

#deletePageOption.disabled {
  opacity: 0.3;
  pointer-events: none;
}

/* Add page dropdown */
#addPageDropdown {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 4px 0;
  min-width: 160px;
}

.add-page-item {
  padding: 8px 16px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  transition: background var(--transition-micro);
}

.add-page-item:hover {
  background: var(--bg-hover);
}

/* ============================
   SUB-TOOLBAR ROW (pages + breadcrumbs)
============================ */

#subToolbarRow {
  position: fixed;
  top: 68px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 1999;
  white-space: nowrap;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  transition: opacity 250ms ease;
}

#subToolbarRow.visible {
  visibility: visible;
  opacity: 1;
}

#subToolbarRow > * {
  pointer-events: all;
}

/* Page switcher — inline, no fixed positioning */
#pageSwitcher {
  display: block;
  flex-shrink: 0;
  transition: transform 360ms cubic-bezier(0.22, 0.9, 0.3, 1);
}

/* Breadcrumb trail — inline, no fixed positioning */
#breadcrumbTrail {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-surface);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-default);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  flex-shrink: 1;
  min-width: 0;

  max-width: 0;
  opacity: 0;
  padding: 0;
  border-color: transparent;
  box-shadow: none;
  transition: max-width 360ms cubic-bezier(0.22, 0.9, 0.3, 1),
              opacity 280ms ease,
              padding 360ms cubic-bezier(0.22, 0.9, 0.3, 1),
              border-color 280ms ease,
              box-shadow 280ms ease;
}

#breadcrumbTrail.visible {
  max-width: 500px;
  opacity: 1;
  padding: 6px 12px;
  border-color: var(--border-default);
  box-shadow: var(--shadow-sm);
}

/* Divider dot between switcher and breadcrumbs */
#breadcrumbTrail::before {
  content: '';
  display: block;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--border-default);
  flex-shrink: 0;
  margin-right: 2px;
  opacity: 0;
  transition: opacity 280ms ease;
}

#breadcrumbTrail.visible::before {
  opacity: 1;
}

/* ============================
   MICRO-INTERACTION POLISH
============================ */

/* Tactile press for all buttons */
#galleryShowMoreBtn:active,
.gallery-card:active {
  transform: scale(0.97) !important;
  transition: transform 60ms ease !important;
}

/* Smooth arm selection flash */
.arm.selected {
  animation: armSelectPulse 300ms ease-out;
}

@keyframes armSelectPulse {
  0% { filter: brightness(1.3); }
  100% { filter: brightness(1); }
}

/* Selection highlight — filter-based, works on any path length */
path.has-outline,
use.has-outline {
  filter: drop-shadow(0 0 4px #2f6fff) drop-shadow(0 0 2px #2f6fff);
}

@keyframes selectGlow {
  from { filter: drop-shadow(0 0 8px #2f6fff) drop-shadow(0 0 4px #2f6fff); }
  to { filter: drop-shadow(0 0 4px #2f6fff) drop-shadow(0 0 2px #2f6fff); }
}

path.has-outline,
use.has-outline {
  animation: selectGlow 300ms ease-out forwards;
}

/* Gallery card press */
.gallery-card:active {
  transform: translateY(-2px) scale(0.985) !important;
  transition: transform 80ms ease !important;
}

/* Smoother panel open/close */
#notesPanel {
  transition: opacity 240ms cubic-bezier(0.22, 0.9, 0.3, 1),
              transform 240ms cubic-bezier(0.22, 0.9, 0.3, 1);
}

#outlinePanel {
  transition: opacity 240ms cubic-bezier(0.22, 0.9, 0.3, 1),
              transform 240ms cubic-bezier(0.22, 0.9, 0.3, 1);
}

/* Page switcher dropdown spring */
#pageSwitcherDropdown {
  transition: opacity 200ms ease,
              transform 280ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

#pageSwitcherDropdown.open {
  transform: translateY(0);
}

/* Toolbar hover lift */
#toolbar button:hover:not(:disabled) {
  transform: translateY(-1px);
  transition: transform 120ms cubic-bezier(0.22, 0.9, 0.3, 1),
              background 120ms ease,
              color 120ms ease;
}

/* Caret smoother blink */
#caret {
  animation: caretBlink 1s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes caretBlink {
  0%, 45% { opacity: 1; }
  55%, 100% { opacity: 0; }
}

/* Status bar message fade */
@keyframes statusFade {
  0% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0.5; }
}

/* Smooth scrollbar everywhere */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-default) transparent;
}

*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 3px;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* Context menu appear */
#contextMenu,
#typeSubmenu,
#pageTabContextMenu,
.gallery-card-context,
#crossLinkMenu,
#addPageTemplateMenu {
  animation: menuAppear 140ms cubic-bezier(0.22, 0.9, 0.3, 1);
  transform-origin: top left;
}

@keyframes menuAppear {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Tooltip appear */
#armTooltip.visible {
  animation: tooltipIn 120ms cubic-bezier(0.22, 0.9, 0.3, 1);
}

@keyframes tooltipIn {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Focus rings for keyboard users */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:focus:not(:focus-visible),
input:focus:not(:focus-visible) {
  outline: none;
}

/* Selection color */
::selection {
  background: rgba(30, 58, 95, 0.15);
  color: inherit;
}

/* Smooth gallery view scroll */
#galleryView {
  scroll-behavior: smooth;
}

/* Notes panel text selection */
#noteText ::selection {
  background: rgba(30, 58, 95, 0.2);
}

/* Better focus for inputs */
input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.08);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

#gallerySearchInput:focus,
#pageSearchInput:focus,
#librarySearchInput:focus {
  border: none;
  box-shadow: none;
}

/* ============================
   AUTH SCREEN
============================ */

/* ============================
   BRAND TRANSITION OVERLAY
============================ */

#brandTransition.brand-transition {
  position: fixed;
  inset: 0;
  /* Must sit above #pageCover (z-index: 999999 inline) */
  z-index: 1000000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms cubic-bezier(0.22, 0.9, 0.3, 1);
  background:
    radial-gradient(circle at 30% 20%, rgba(30, 58, 95, 0.06) 0%, transparent 55%),
    radial-gradient(circle at 70% 70%, rgba(153, 27, 27, 0.05) 0%, transparent 55%),
    var(--bg-canvas);
}

#brandTransition.brand-transition.show {
  opacity: 1;
  pointer-events: all;
}

#brandTransition .brand-transition-card {
  width: min(420px, 92vw);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 18px;
  box-shadow: 0 26px 80px rgba(16, 20, 24, 0.10);
  padding: 34px 32px 30px;
  text-align: center;
}

#brandTransition .brand-transition-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--accent);
  margin-bottom: 18px;
}

#brandTransition .brand-transition-wordmark {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent);
}

#brandTransition .brand-transition-spinner {
  width: 22px;
  height: 22px;
  margin: 0 auto 14px;
  border-radius: 50%;
  border: 2px solid rgba(30, 58, 95, 0.18);
  border-top-color: var(--accent);
  animation: brandSpin 0.65s linear infinite;
}

#brandTransition .brand-transition-title {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

#brandTransition .brand-transition-subtitle {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.45;
}

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

@media (prefers-reduced-motion: reduce) {
  #brandTransition.brand-transition {
    transition: none;
  }
  #brandTransition .brand-transition-spinner {
    animation: none;
  }
}

#authScreen {
  position: fixed;
  inset: 0;
  z-index: 20000;
  background: var(--bg-canvas);
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 350ms cubic-bezier(0.22, 0.9, 0.3, 1);
}

#authScreen.visible {
  opacity: 1;
}

#authScreen.hidden {
  opacity: 0;
  pointer-events: none;
}

#authCard {
  width: 100%;
  max-width: 400px;
  padding: 48px 40px 40px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(16, 20, 24, 0.08);
}

#authLogo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--accent);
}

#authLogoText {
  font-family: 'Playfair Display', serif;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent);
}

#authSubtitle {
  text-align: center;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text-tertiary);
  margin: 0 0 32px;
}

.auth-title {
  font-family: 'Inter', sans-serif;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 20px;
  text-align: center;
}

.auth-desc {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--text-secondary);
  margin: -12px 0 20px;
  text-align: center;
  line-height: 1.5;
}

/* OAuth button */
.auth-oauth-btn {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.auth-oauth-btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-tertiary);
  box-shadow: 0 2px 8px rgba(16, 20, 24, 0.06);
}

.auth-oauth-btn:active {
  transform: scale(0.98);
  transition: transform 60ms ease;
}

/* Divider */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 20px 0;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-default);
}

.auth-divider span {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Fields */
.auth-field {
  margin-bottom: 16px;
}

.auth-field label {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.auth-field input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-surface);
  outline: none;
  box-sizing: border-box;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.auth-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.08);
}

.auth-field input::placeholder {
  color: var(--text-tertiary);
}

/* Primary button */
.auth-primary-btn {
  width: 100%;
  padding: 11px 16px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--text-inverse);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast), transform 60ms ease;
  margin-top: 4px;
}

.auth-primary-btn:hover {
  background: var(--brand-hover);
}

.auth-primary-btn:active {
  transform: scale(0.985);
}

.auth-primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.auth-primary-btn.loading {
  position: relative;
  color: transparent;
}

.auth-primary-btn.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: authSpin 0.6s linear infinite;
}

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

/* Error and success messages */
.auth-error {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: #991B1B;
  background: rgba(153, 27, 27, 0.06);
  border: 1px solid rgba(153, 27, 27, 0.15);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 12px;
  display: none;
  line-height: 1.4;
}

.auth-error.visible {
  display: block;
  animation: authShake 300ms ease;
}

@keyframes authShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.auth-success {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: #166534;
  background: rgba(22, 101, 52, 0.06);
  border: 1px solid rgba(22, 101, 52, 0.15);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 12px;
  display: none;
  line-height: 1.4;
}

.auth-success.visible {
  display: block;
}

/* Footer links */
.auth-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.auth-link-btn {
  background: none;
  border: none;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  transition: color var(--transition-fast);
}

*{margin:0;padding:0;box-sizing:border-box}
html{background:#FBFBFA}

.auth-link-btn:hover {
  color: var(--brand-hover);
  text-decoration: underline;
}

.auth-footer-text {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--text-tertiary);
}

.auth-footer-sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--border-default);
}

/* Auth form transitions */
.auth-form {
  animation: authFadeIn 400ms 100ms cubic-bezier(0.22, 0.9, 0.3, 1) both;
}

#authCard {
  animation: authCardIn 450ms 50ms cubic-bezier(0.22, 0.9, 0.3, 1) both;
}

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

@keyframes authCardIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================
   USER AVATAR & MENU
============================ */

#userMenuContainer {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}

#userAvatarBtn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border-default);
  background: var(--accent);
  color: var(--text-inverse);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

#userAvatarBtn:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

#userMenu {
  position: absolute;
  /* Start hidden and without a set position */
  display: none; 
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  z-index: 10001;
  /* Remove 'right: 0' so it doesn't fight with our JS placement */
}

/* When the JS adds the .show class */
#userMenu.show {
  display: block !important;
}

#userMenuInfo {
  padding: 14px 16px 10px;
}

#userMenuName {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

#userMenuEmail {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--text-tertiary);
  word-break: break-all;
}

.user-menu-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 4px 0;
}

#userMenu .menu-item {
  padding: 10px 16px;
  font-size: 13px;
}

/* Hide auth-dependent elements before login */
body.auth-loading #toolbar,
body.auth-loading #statusBar,
body.auth-loading #whirlybird,
body.auth-loading #galleryView,
body.auth-loading .edge-tab,
body.auth-loading #addArmBtn,
body.auth-loading #subToolbarRow {
  display: none !important;
}

@media (max-width: 480px) {
  #authCard {
    margin: 16px;
    padding: 32px 24px;
  }
}

/* Selected arm dragger always visible and prioritized */
.arm-dragger.active-dragger {
  opacity: 0;
  r: 12;
  pointer-events: all !important;
  z-index: 9999;
}

.arm-dragger.active-dragger:hover {
  opacity: 1;
}
/* ============================
   VERSION HISTORY MODAL
============================ */

#versionHistoryModal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(28, 25, 23, 0.6);
  backdrop-filter: blur(4px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#versionHistoryContent {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 92%;
  max-width: 780px;
  height: 80vh;
  max-height: 600px;
  display: flex;
  flex-direction: column;
  animation: panelSlideIn 0.25s cubic-bezier(0.22, 0.9, 0.3, 1);
  overflow: hidden;
}

#versionHistoryHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

#versionHistoryHeaderLeft {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
}

#versionHistoryHeaderLeft svg {
  color: var(--text-tertiary);
}

#closeVersionHistoryBtn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 0;
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
}

#closeVersionHistoryBtn:hover { color: var(--text-primary); }

/* Split layout */
#versionHistoryBody {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

#versionListPane {
  width: 280px;
  flex-shrink: 0;
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
  padding: 8px;
}

#versionListPane::-webkit-scrollbar { width: 4px; }
#versionListPane::-webkit-scrollbar-track { background: transparent; }
#versionListPane::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 2px; }

#versionPreviewPane {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg-subtle);
  min-width: 0;
}

#versionPreviewSvg {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
}

#versionPreviewSvg svg {
  max-width: 100%;
  max-height: 100%;
}

#versionPreviewMeta {
  text-align: center;
  padding-top: 16px;
  flex-shrink: 0;
}

#versionPreviewLabel {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

#versionPreviewDate {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}

#versionPreviewStats {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: var(--text-tertiary);
}

/* Version list items */
.version-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-micro);
  position: relative;
}

.version-item:hover { background: var(--bg-hover); }
.version-item.active { background: var(--accent-subtle); }

.version-item.current .version-dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.12);
}

.version-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-default);
  flex-shrink: 0;
  margin-top: 4px;
  transition: background var(--transition-fast);
}

.version-item.active .version-dot { background: var(--accent); }

.version-line {
  position: absolute;
  left: 18px;
  top: 26px;
  bottom: -6px;
  width: 1px;
  background: var(--border-subtle);
  pointer-events: none;
}

.version-item:last-child .version-line { display: none; }

.version-info { flex: 1; min-width: 0; }

.version-label-text {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.version-item.current .version-label-text { font-weight: 600; }

.version-date-text {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
  line-height: 1.3;
}

.version-badge {
  display: inline-block;
  font-family: 'Inter', sans-serif;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--accent);
  color: var(--text-inverse);
  margin-top: 4px;
}

/* Footer */
#versionHistoryFooter {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

#versionCountLabel {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--text-tertiary);
}

#restoreVersionBtn {
  padding: 8px 20px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--text-inverse);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast), transform 60ms ease;
}

#restoreVersionBtn:hover:not(:disabled) { background: var(--brand-hover); }
#restoreVersionBtn:active:not(:disabled) { transform: scale(0.97); }

#restoreVersionBtn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Empty state */
.version-empty {
  padding: 40px 20px;
  text-align: center;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--text-tertiary);
  line-height: 1.6;
}

.version-empty svg {
  display: block;
  margin: 0 auto 12px;
  color: var(--border-default);
}

/* ============================
   GALLERY TRASH
============================ */

#galleryTrash {
  max-width: 1200px;
  margin: 0 auto 32px;
  padding: 0 48px 32px;
  transition: margin-bottom 400ms cubic-bezier(0.22, 0.9, 0.3, 1);
}

#galleryTrashHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 16px;
  transition: margin-bottom 400ms cubic-bezier(0.22, 0.9, 0.3, 1);
}

#galleryTrashHeaderLeft {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#galleryTrashHeaderLeft svg { color: var(--text-tertiary); }

#galleryTrashHeaderRight {
  display: flex;
  align-items: center;
  gap: 8px;
}

#emptyTrashBtn {
  background: none;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

#emptyTrashBtn:hover {
  color: #991B1B;
  border-color: #991B1B;
  background: rgba(153, 27, 27, 0.04);
}

#galleryTrashToggle {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast), transform 400ms cubic-bezier(0.22, 0.9, 0.3, 1);
}

#galleryTrashToggle:hover { color: var(--text-primary); }
#galleryTrashToggle.collapsed { transform: rotate(-90deg); }

#galleryTrashGrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
  max-height: 2000px;
  opacity: 1;
  overflow: hidden;
  transition: max-height 400ms cubic-bezier(0.22, 0.9, 0.3, 1),
              opacity 300ms ease,
              padding 400ms cubic-bezier(0.22, 0.9, 0.3, 1);
}

#galleryTrashGrid.collapsed {
  max-height: 0;
  opacity: 0;
  padding: 0;
}

#galleryTrashGrid.collapsed + #trashAutoDeleteNote {
  max-height: 0;
  opacity: 0;
  padding: 0;
  overflow: hidden;
}

#galleryTrashGrid.collapsed ~ #trashAutoDeleteNote {
  max-height: 0;
  opacity: 0;
  padding: 0;
  overflow: hidden;
}

#galleryTrashGrid.collapsed + #trashAutoDeleteNote,
#galleryTrashGrid.collapsed ~ #trashAutoDeleteNote {
  max-height: 0;
  opacity: 0;
  padding: 0;
  overflow: hidden;
}

@media (max-width: 1000px) {
  #galleryTrash { padding: 0 24px 32px; }
  #galleryTrashGrid { grid-template-columns: repeat(2, 1fr); gap: 20px; }
}
@media (max-width: 600px) {
  #galleryTrash { padding: 0 16px 32px; }
  #galleryTrashGrid { grid-template-columns: 1fr; gap: 16px; }
}

/* Trash cards */
.gallery-card.trashed {
  opacity: 0.6;
  border-style: dashed;
}

.gallery-card.trashed:hover {
  opacity: 0.9;
}

.gallery-card.trashed .gallery-card-preview {
  filter: grayscale(0.4);
}

.trash-card-actions {
  display: flex;
  gap: 8px;
  padding: 0 20px 14px;
}

.trash-restore-btn,
.trash-permanent-btn {
  flex: 1;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
  border: 1px solid var(--border-default);
}

.trash-restore-btn {
  background: var(--accent);
  color: var(--text-inverse);
  border-color: var(--accent);
}

.trash-restore-btn:hover { background: var(--brand-hover); }

.trash-permanent-btn {
  background: var(--bg-surface);
  color: var(--text-tertiary);
}

.trash-permanent-btn:hover {
  color: #991B1B;
  border-color: #991B1B;
  background: rgba(153, 27, 27, 0.04);
}

.trash-deleted-date {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: var(--text-tertiary);
  font-style: italic;
}

#trashAutoDeleteNote {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: var(--text-tertiary);
  text-align: center;
  padding: 12px 0 0;
  font-style: italic;
  max-height: 60px;
  opacity: 1;
  transition: max-height 400ms cubic-bezier(0.22, 0.9, 0.3, 1),
              opacity 300ms ease,
              padding 400ms cubic-bezier(0.22, 0.9, 0.3, 1);
}

/* ============================
   TIER GATING
============================ */

/* Reserved for future pro-gated UI elements */

.upgrade-inline {
  color: var(--accent);
  text-decoration: underline;
  font-weight: 600;
  cursor: pointer;
}

/* Pro badge for inline gated buttons */
.pro-badge-inline {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--accent);
  color: var(--text-inverse);
  font-family: 'Inter', sans-serif;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-left: 4px;
  vertical-align: middle;
  line-height: 1.4;
}

.pro-locked-inline {
  opacity: 0.7;
  cursor: pointer;
}

.pro-locked-inline:hover {
  opacity: 1;
}

/* Free tier: project limit reached */
body.at-project-limit .gallery-card-new {
  opacity: 0.5;
  border-color: var(--text-tertiary);
}

body.at-project-limit .gallery-card-new::after {
  content: 'Monthly limit reached · Upgrade for unlimited';
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: var(--accent);
  font-weight: 500;
  white-space: nowrap;
}

body.at-project-limit .gallery-card-new .gallery-card-new-label {
  display: none;
}

/* User menu: show tier badge */
.tier-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tier-badge-free {
  background: var(--bg-subtle);
  color: var(--text-tertiary);
  border: 1px solid var(--border-default);
}

.tier-badge-pro {
  background: var(--accent);
  color: var(--text-inverse);
}

/* ============================
   LOADING BAR (top of viewport)
============================ */

#loadingBar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 99999;
  pointer-events: none;
  overflow: hidden;
  opacity: 0;
  transition: opacity 180ms ease;
}

#loadingBar.active {
  opacity: 1;
}

#loadingBar .loading-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #3B6B9F);
  border-radius: 0 2px 2px 0;
  width: 0;
  animation: loadBarFill 2.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

#loadingBar.done .loading-bar-inner {
  width: 100% !important;
  animation: none;
  transition: width 180ms ease;
}

#loadingBar.done {
  opacity: 0;
  transition: opacity 350ms 180ms ease;
}

@keyframes loadBarFill {
  0%   { width: 0; }
  12%  { width: 20%; }
  35%  { width: 50%; }
  60%  { width: 72%; }
  85%  { width: 86%; }
  100% { width: 92%; }
}

/* ============================
   GALLERY CARD LOADING STATE
============================ */

.gallery-card-preview {
  position: relative;
}

.gallery-card.loading {
  pointer-events: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 8px 24px rgba(30, 58, 95, 0.12);
  transform: translateY(-4px) scale(1.01);
}

.gallery-card.loading .gallery-card-preview::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(251, 251, 250, 0.75);
  backdrop-filter: blur(2px);
  z-index: 5;
  animation: cardOverlayIn 200ms ease forwards;
}

.gallery-card.loading .gallery-card-preview::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border: 2.5px solid var(--border-default);
  border-top-color: var(--accent);
  border-radius: 50%;
  z-index: 6;
  animation: cardLoadSpin 0.65s linear infinite;
}

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

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

.gallery-card.loading .gallery-card-name {
  color: var(--accent);
}

/* ============================
   GALLERY SKELETON CARDS
============================ */

.gallery-card-skeleton {
  background: linear-gradient(180deg, var(--bg-surface) 0%, #FBFBFB 100%);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-height: 290px;
  display: flex;
  flex-direction: column;
  animation: skeletonFadeIn 300ms ease both;
}

.gallery-card-skeleton:nth-child(1) { animation-delay: 0ms; }
.gallery-card-skeleton:nth-child(2) { animation-delay: 50ms; }
.gallery-card-skeleton:nth-child(3) { animation-delay: 100ms; }
.gallery-card-skeleton:nth-child(4) { animation-delay: 150ms; }
.gallery-card-skeleton:nth-child(5) { animation-delay: 200ms; }
.gallery-card-skeleton:nth-child(6) { animation-delay: 250ms; }

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

.skeleton-preview {
  height: 220px;
  background: var(--bg-subtle);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.skeleton-preview::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.5) 40%,
    rgba(255, 255, 255, 0.5) 60%,
    transparent 100%
  );
  animation: skeletonShimmer 1.8s ease-in-out infinite;
}

@keyframes skeletonShimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Whirlybird ghost icon in skeleton preview */
.skeleton-preview::before {
  content: '';
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--border-default);
  opacity: 0.3;
}

.skeleton-info {
  padding: 18px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skeleton-line {
  border-radius: 6px;
  background: var(--bg-subtle);
}

.skeleton-line.title {
  width: 55%;
  height: 14px;
}

.skeleton-line.meta {
  width: 35%;
  height: 10px;
}

/* ============================
   GALLERY CARD ENTRANCE ANIMATION
============================ */

/* Card entrance — intentionally static. No stagger, no jank. */

/* ============================
   CANVAS REVEAL ANIMATION
============================ */

#whirlybird.canvas-revealing {
  animation: canvasReveal 450ms cubic-bezier(0.22, 0.9, 0.3, 1) forwards;
}

@keyframes canvasReveal {
  from {
    opacity: 0;
    filter: blur(3px);
  }
  to {
    opacity: 1;
    filter: blur(0);
  }
}

/* ============================
   TOUCH / MOBILE (no desktop change)
   Only applies when primary input is coarse (touch).
============================ */
@media (hover: none) and (pointer: coarse) {
  /* Minimum 44px touch targets; no 300ms delay on tap */
  #toolbar button,
  .menu-item,
  .auth-primary-btn,
  .auth-oauth-btn,
  .auth-link-btn,
  #addArmBtn,
  .dropdown button,
  .gallery-card,
  .edge-tab,
  .breadcrumb-item,
  [role="tab"] {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
  }
  #toolbar {
    padding: 10px 14px;
    top: max(12px, env(safe-area-inset-top));
    -webkit-tap-highlight-color: transparent;
  }
  #toolbar button {
    padding: 10px 16px;
  }
  #addArmBtn {
    bottom: max(20px, env(safe-area-inset-bottom));
    right: max(20px, env(safe-area-inset-right));
    width: 52px;
    height: 52px;
    line-height: 52px;
  }
  .user-avatar,
  #userAvatarBtn {
    min-width: 44px;
    min-height: 44px;
  }
  #contextMenu .menu-item,
  #typeSubmenu .submenu-item {
    min-height: 44px;
    padding: 12px 16px;
    touch-action: manipulation;
  }
  /* Prevent pull-to-refresh / overscroll on canvas area */
  #whirlybird {
    touch-action: pan-x pan-y pinch-zoom;
  }
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
  }
}