/**
 * PitaraAI - Global Stylesheet
 * =======================================
 * Layout, components, and animations for home and collection pages.
 * Uses CSS variables for design tokens; supports light/dark card states.
 * 
 * Structure:
 * - Global base styles and CSS variables
 * - Home page components (collections grid, hero input)
 * - Collection page: header, stats, cards grid, and expanded modals
 * - Card styles: collapsed state (icon + label) and expanded overlays
 * - Code editor modal and media viewer modal
 * - Hover animations and transitions
 */

html, body { width: 100%; height: 100%; overflow-x: hidden; }
body { background: #313131 !important; color: #f0f0f0; }

/* ===== Design Tokens (CSS Variables) ===== */
:root {
	/* Typography */
	--font-family: 'Arimo', Arial, sans-serif;

	/* Colors */
	--color-bg: #f8f9fa;
	--color-surface: #ffffff;
	--color-muted-surface: #f1f3f5;
	--color-primary: #0d6efd;
	--plus-btn-bg: #dbdcdd;
	--plus-btn-hover: #b6b8b9;

	/* Shadows */
	--card-shadow: 0 8px 12px rgba(15,15,15,0.06);
	--input-shadow: 0 8px 22px rgba(15,15,15,0.06);

	/* Sizes */
	--home-square-width: 220px;
	--home-square-height: 140px;
	--top-rect-width: 32%;
	--top-rect-min-height: 160px;
	--media-thumb-width: 140px;
	--media-thumb-height: 88px;

	/* Responsive Breakpoints
	 * These match BREAKPOINTS in design-tokens.js
	 * Note: CSS variables cannot be used in @media queries (CSS limitation),
	 * but they serve as documentation and can be read by JavaScript.
	 * See documents/BREAKPOINTS_LOCATION.md for usage guide.
	 */
	--breakpoint-sm: 640px;   /* Small devices (tablets) */
	--breakpoint-md: 768px;   /* Medium devices (small desktops) */
	--breakpoint-lg: 1024px;  /* Large devices (desktops) */
	--breakpoint-xl: 1280px;  /* Extra large devices (large desktops) */
	--breakpoint-2xl: 1536px; /* 2X Extra large devices */
}

/* ===== Reusable Button Components ===== */

/* Base icon button - dark theme with blue glow border */
.btn-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: #3d3d4d;
  border: 1px solid rgba(190, 219, 255, 0.5);
  box-shadow: 0px 0px 0px 1px rgba(190, 219, 255, 0.5), 0px 10px 15px -3px rgba(0, 0, 0, 0.1), 0px 4px 6px -4px rgba(0, 0, 0, 0.1);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  opacity: 0.5;
  flex-shrink: 0;
}

.btn-icon:hover {
  opacity: 1;
  transform: scale(1.05);
  box-shadow: 0px 0px 0px 2px rgba(190, 219, 255, 0.7), 0px 10px 15px -3px rgba(0, 0, 0, 0.15), 0px 4px 6px -4px rgba(0, 0, 0, 0.15);
}

.btn-icon.active,
.btn-icon:focus {
  opacity: 1;
}

.btn-icon:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
}

/* Small variant */
.btn-icon.btn-sm {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

/* Medium variant (default is 48px) */
.btn-icon.btn-md {
  width: 44px;
  height: 44px;
  border-radius: 14px;
}

/* Large variant */
.btn-icon.btn-lg {
  width: 56px;
  height: 56px;
  border-radius: 16px;
}

/* Ghost button - transparent with subtle border */
.btn-ghost {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}

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

/* Primary button - solid blue */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.15);
}

.btn-primary:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.2);
}

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

.btn-primary:disabled {
  background: #6b7280;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Secondary button - gray/neutral */
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  background: #E5E7EB;
  color: #374151;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-secondary:hover {
  background: #D1D5DB;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Dark theme secondary button */
body.dark-theme .btn-secondary {
  background: #3d3d3d;
  color: #e5e7eb;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-theme .btn-secondary:hover {
  background: #4d4d4d;
  border-color: rgba(255, 255, 255, 0.2);
}

/* Danger/Delete button */
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  background: #ef4444;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-danger:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

/* Circle button (for menu dots, close buttons) */
.btn-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-circle:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.1);
}

/* Light theme circle button */
.btn-circle.btn-circle-light {
  background: rgba(0, 0, 0, 0.05);
  color: #374151;
}

.btn-circle.btn-circle-light:hover {
  background: rgba(0, 0, 0, 0.1);
}

.container-center { min-height: 80vh; display:flex; align-items:center; justify-content:center; }

.card pre { background:#212121; color:#e6e6e6; padding:8px; overflow:auto }

/* ===== Home Page Styles ===== */
.container-center { min-height: 80vh; display:flex; align-items:center; justify-content:center; }

.card pre { background:#212121; color:#e6e6e6; padding:8px; overflow:auto }

/* Home page title */
.home-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: #1F2937;
  text-align: center;
  margin: 0;
  letter-spacing: -0.02em;
}

/* Collections grid on home page */
.empty-collections-grid { display:flex; gap:16px; }
.home-cards-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 24px;
  max-width: 1200px;
  width: 100%;
  padding: 20px;
}

/* Home page collection card - preview style */
.home-collection-card {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 20px;
  position: relative;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
  background: #f3f4f6;
}

.home-collection-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

/* Gradient background for collection card */
.home-collection-card-gradient {
  background: linear-gradient(135deg, #8B5CF6 0%, #6366F1 50%, #3B82F6 100%);
  width: 100%;
  height: 100%;
  position: relative;
}

/* Collection name label on gradient card */
.home-collection-label {
  position: absolute;
  bottom: 16px;
  left: 16px;
  color: white;
  font-size: 16px;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  z-index: 2;
}

/* Collection preview grid (2x2 items) */
.collection-preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 2px;
  width: 100%;
  height: 100%;
  background: #fff;
}

.collection-preview-item {
  width: 100%;
  height: 100%;
  background: #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.collection-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.collection-preview-item.text-preview {
  background: linear-gradient(135deg, #ffffff 0%, #f3f4f6 100%);
  padding: 8px;
  font-size: 10px;
  line-height: 1.4;
  color: #1f2937;
  overflow: hidden;
  text-overflow: ellipsis;
}

.collection-preview-item.code-preview {
  background: #1e1e1e;
  padding: 6px;
  font-family: monospace;
  font-size: 8px;
  color: #d4d4d4;
  overflow: hidden;
}

.collection-preview-item.mesh-preview {
  background: #0f1116;
  color: #4ade80;
  font-size: 24px;
}

.collection-preview-item.empty-preview {
  background: #f9fafb;
  color: #9ca3af;
  font-size: 12px;
}

/* Collection card overlay with name and count - positioned at bottom */
.collection-card-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.6) 60%, transparent 100%);
  padding: 16px;
  color: white;
  z-index: 2;
}

.collection-card-name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  line-height: 1.3;
}

.collection-card-count {
  font-size: 12px;
  opacity: 0.9;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.collection-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.collection-card-date {
  font-size: 12px;
  opacity: 0.8;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Collection card menu button (three dots) */
.collection-card-menu {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
  color: #374151;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
  z-index: 10;
}

.collection-card-menu:hover {
  background: white;
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Dropdown menu for collection card */
.collection-menu-dropdown {
  position: absolute;
  top: 48px;
  right: 12px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  min-width: 120px;
  z-index: 1000;
  overflow: hidden;
}

.collection-menu-item {
  padding: 10px 16px;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  color: #374151;
  transition: background 0.15s ease;
}

.collection-menu-item:hover {
  background: #f3f4f6;
}

.collection-menu-item.delete {
  color: #ef4444;
}

.collection-menu-item.delete:hover {
  background: #fee2e2;
}

/* Add collection card - gray style */
.home-add-card {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 20px;
  background: #E5E7EB;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.home-add-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
  background: #D1D5DB;
}

/* Plus sign in add card */
.home-add-plus {
  font-size: 64px;
  font-weight: 300;
  color: #1F2937;
  line-height: 1;
  user-select: none;
}

/* Legacy styles for backward compatibility */
.plus-square { background:#e9ecef; border-radius:12px; width:120px; height:120px; display:flex; align-items:center; justify-content:center; position:relative; box-shadow: var(--card-shadow) }
.plus-btn { width:44px; height:44px; border-radius:50%; background:var(--plus-btn-bg); border:2px dashed #adb5bd; display:flex; align-items:center; justify-content:center; font-size:24px; cursor:pointer }
.plus-square .plus-btn:hover { background:var(--plus-btn-hover) }

/* Empty collection placeholders and cards */
.coder-pad { background:#e9ecef; border-radius:12px; padding:18px; min-height:120px; display:flex; align-items:center; justify-content:center; cursor:pointer; box-shadow: var(--card-shadow) }
.coder-pad.expanded { min-height:200px }
.example-cards { display:flex; gap:12px; margin-top:12px }
.example-card { background:#e9ecef; border-radius:12px; width:240px; height:140px; display:flex; align-items:center; justify-content:center; overflow:hidden; box-shadow: var(--card-shadow) }
.example-card img, .example-card iframe { width:100%; height:100%; object-fit:cover; border-radius:12px }
.example-card .card-overlay { position:absolute; right:8px; bottom:8px }

/* ===== Layout & Containers ===== */
.container { max-width:1200px }
.form-control-lg { padding:0.75rem 1rem; font-size:1rem }
#whatInput { max-width: 640px; width:100%; box-shadow: var(--input-shadow); }
#hero label { font-size:1.25rem; font-weight:600 }

/* Collection cards grid layout (inspired by shopping/inspiration cards) */
.collection-cards-grid { display:flex; gap:16px; width:100%; flex-wrap:wrap; }

/* Organize mode styles */
.collection-card.organize-mode-active {
  cursor: grab;
  user-select: none;
}

.collection-card.organize-mode-active:active {
  cursor: grabbing;
}

/* Disable hover effects during organize mode */
.collection-card.organize-mode-active:hover {
  transform: none;
}

/* Drag placeholder - shown where card will be dropped */
.drag-placeholder {
  background: rgba(59, 130, 246, 0.15);
  border: 2px dashed rgba(59, 130, 246, 0.5);
  border-radius: 16px;
  pointer-events: none;
}

/* Drag clone - follows the mouse */
.drag-clone {
  border-radius: 16px;
  overflow: hidden;
}

.drag-clone .card-background {
  border-radius: 16px;
}

/* Legacy drag-over style (for backwards compatibility) */
.collection-card.drag-over {
  opacity: 0.5;
  transform: scale(1.05);
  border: 2px solid rgba(59, 130, 246, 0.8);
}

/* ===== Large card variant (centred gallery look) ===== */
/* Use when the template wants a visually larger card (see collection view) */
.collection-card.large,
.collection-card.large-card {
  flex: 0 0 320px;
  min-width: 320px;
  max-width: 360px;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(15,15,15,0.08);
}
.collection-card.large .card-background,
.collection-card.large-card .card-background {
  border-radius: 18px;
}
.collection-card.large .card-inner, .collection-card.large-card .card-inner { border-radius: 18px; }

/* Card title - now interactive for editing */
.card-background .card-label-title { 
  cursor: text;
  user-select: none;
  pointer-events: auto !important;
  position: relative;
  z-index: 11;
}
.card-background .card-label-title:hover {
  opacity: 0.8;
}

/* Slightly larger icon for large cards */
.collection-card.large .card-icon, .collection-card.large-card .card-icon { width:20px; height:20px; }

/* Add-dropdown styles (small menu under the + toggle) */
.add-dropdown {
  background:#fff;
  border-radius:10px;
  box-shadow:0 12px 40px rgba(0,0,0,0.12);
  padding:8px;
  display:flex;
  flex-direction:column;
  gap:8px;
  min-width:120px;
  z-index:1500;
}
.add-dropdown .add-option {
  background:transparent;
  border:none;
  padding:8px 12px;
  text-align:left;
  cursor:pointer;
  font-weight:700;
  border-radius:8px;
}
.add-dropdown .add-option:hover { background:rgba(0,0,0,0.04); }

/* Card hover animation (match Example MediaCard behavior) */
.collection-card {
  transition: transform 260ms ease, box-shadow 260ms ease;
  min-width:160px;
  flex: 1 1 180px;
}
.collection-card:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 14px 32px rgba(15,15,15,0.10);
}

/* Image zoom on hover */
.collection-card .card-inner img {
  transition: transform 300ms ease;
  transform-origin: center center;
}
.collection-card:hover .card-inner img {
  transform: scale(1.06);
}

/* Gradient overlay that fades in on hover */
/* Hover gradient overlay disabled - using permanent gradient via ::before */
.card-background::after {
  display: none;
}

/* ===== Card Menu Button (Collection Page Cards) ===== */
/* Three-dot menu that appears on hover in top-right corner */
.card-menu-container {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 20;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 200ms ease, transform 200ms ease;
}

.collection-card:hover .card-menu-container {
  opacity: 1;
  transform: translateY(0);
}

.card-menu-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  color: #fff;
  letter-spacing: 1px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: all 0.15s ease;
}

.card-menu-btn:hover {
  background: rgba(0, 0, 0, 0.85);
  transform: scale(1.05);
}

/* Hide More options button when card is expanded */
.collection-card.expanded .card-menu-container {
  display: none !important;
}

.card-menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  min-width: 190px;
  background: rgba(30, 30, 35, 0.98);
  backdrop-filter: blur(12px);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  z-index: 100;
}

.card-menu-option {
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #e0e0e0;
  transition: background 0.15s ease;
  text-align: left;
}

.card-menu-option:hover {
  background: rgba(255, 255, 255, 0.1);
}

.card-menu-option svg,
.card-menu-option img.card-menu-option-icon {
  flex-shrink: 0;
}

.card-menu-option-danger {
  color: #ef4444;
}

.card-menu-option-danger:hover {
  background: rgba(239, 68, 68, 0.15);
}

/* ===== Hover & Action Buttons ===== */
/* Top-right action that appears on hover (if markup adds .card-action) */
.card-action { position:absolute; top:12px; right:12px; z-index:12; opacity:0; transform: translateY(-6px); transition: opacity 240ms ease, transform 240ms ease; }
.collection-card:hover .card-action { opacity:1; transform: translateY(0); }

/* Add Media button in card */
.card-add-media {
  width:36px;
  height:36px;
  border-radius:8px;
  background:rgba(37,99,235,0.9);
  border:none;
  display:flex;
  align-items:center;
  justify-content:center;
  color:#fff;
  cursor:pointer;
  transition: background-color 200ms, transform 200ms;
  box-shadow: 0 4px 12px rgba(37,99,235,0.2);
}
.card-add-media:hover { background:rgba(30,64,175,0.95); transform: scale(1.08); }

/* Header buttons and CTA styles (inspired by Example project) */
.icon-btn {
  padding:8px;
  border-radius:8px;
  background:#fff;
  border:1px solid #e6e6e6;
  cursor:pointer;
  transition: background-color .18s ease, transform .12s ease;
}
.icon-btn:hover { background:#f5f7f9; transform:translateY(-1px); }

/* Add button styling */
.collection-add-btn:hover {
  background:#D1D5DB !important;
  transform: scale(1.05);
}


/* Dropdown menu styling */
.add-dropdown-menu {
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.add-dropdown-option:hover {
  background:#F3F4F6 !important;
}

/* Media Add Panel Modal */
.media-add-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
}
.media-add-panel-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}
.media-add-panel-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: 16px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translate(-50%, -45%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}
.media-add-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #E5E7EB;
}
.media-add-panel-body {
  padding: 24px;
}
.media-add-panel-close:hover {
  background: #E5E7EB !important;
}

/* Drop zone styling */
.drop-zone {
  position: relative;
}
.drop-zone:hover {
  border-color: #2563EB !important;
  background: #EFF6FF !important;
}
.drop-zone.drag-over {
  border-color: #2563EB !important;
  background: #DBEAFE !important;
  transform: scale(1.02);
}

.primary-btn {
  display:inline-flex;
  gap:8px;
  padding:10px 16px;
  background:#2563eb;
  color:#fff;
  border-radius:12px;
  transition: background-color .18s ease, box-shadow .18s ease, transform .12s ease;
  box-shadow: 0 8px 20px rgba(37,99,235,0.12);
  border: none;
  font-weight:600;
}
.primary-btn:hover { background:#1e40af; transform:translateY(-1px); box-shadow: 0 14px 30px rgba(37,99,235,0.14); }

/* Stats cards */
.stats-grid { display:grid; grid-template-columns: repeat(4, 1fr); gap:12px; }
.stat-card { background:#fff; border-radius:12px; padding:12px; box-shadow: 0 6px 18px rgba(15,15,15,0.03); border:1px solid #f1f3f5; }
.stat-label { color:#6b7280; font-size:13px; margin-bottom:6px }
.stat-value { font-size:18px; font-weight:700; color:#111827 }

/* Add new collection CTA (dashed) - map to .add-collection-cta if present */
.add-collection-cta { width:100%; display:block; min-width:300px; padding:24px; border-radius:20px; border:2px dashed #d1d5db; background:#fff; transition: border-color .25s, background-color .25s; }
.add-collection-cta:hover { border-color:#60a5fa; background: rgba(59,130,246,0.04); }

/* group-hover helpers (for nested icon color changes) */
.group-hover-icon { transition: background-color .18s, color .18s; }
.group:hover .group-hover-icon { background:#bfdbfe; color:#2563eb; }

/* Individual card styling */
.collection-card { flex:1; min-width:200px; cursor:pointer; position:relative; }
.collection-page-card {
  /* Dimensions set by masonry-grid.js based on aspect ratio */
  width: 280px;
  height: auto;
  flex: 0 0 280px;
  overflow: hidden;
}

/* Landscape and portrait card dimensions are set dynamically via inline styles 
   in JavaScript based on detected aspect ratio (16:9, 4:3, etc.) */

/* Square cards (approximately 1:1) */
.collection-page-card.card-square {
  width: 288px;
  height: 288px;
  flex: 0 0 288px;
}
.card-background {
  position:relative;
  width:100%;
  height:100%;
  border-radius:16px;
  overflow:hidden;
  background:var(--color-muted-surface);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  display:flex;
  align-items:center;
  justify-content:center;
}

/* Bottom gradient overlay for card (from example/card design) */
.card-background::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100%;
  background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.2) 50%, rgba(0,0,0,0) 100%);
  z-index: 5;
  pointer-events: none;
}

/* Hover gradient border effect - direction controlled by mouse position via JS */
.collection-card {
  --gradient-angle: 135deg;
}

.collection-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 16px;
  padding: 2px;
  background: linear-gradient(var(--gradient-angle), #ff6b6b, #feca57, #48dbfb, #ff9ff3, #ff6b6b);
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.collection-card:hover::before {
  opacity: 1;
}

.collection-card .card-background {
  position: relative;
  z-index: 1;
}

/* Card icon base styles - positioning handled by .card-bottom-bar */
.card-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.card-icon svg {
  width: 24px;
  height: 24px;
  stroke: #fff;
  stroke-width: 2;
  fill: none;
}

/* Card inner content (fills background) */
.card-inner { 
  position:absolute;
  top:0;
  left:0;
  width:100%;
  height:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  background:linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.mesh-card-icon {
  width:60%;
  height:60%;
  border-radius:18px;
  background:linear-gradient(145deg, #1f1f2b 0%, #36364a 100%);
  display:flex;
  align-items:center;
  justify-content:center;
  box-shadow:inset 0 0 12px rgba(255,255,255,0.08);
}
.mesh-card-icon svg {
  width:60%;
  height:60%;
  fill:none;
  stroke:#e5e7ff;
  stroke-width:1.8px;
}

/* Card bottom bar - container for title and icon */
.card-bottom-bar {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

/* Enable pointer events on title within bottom bar */
.card-bottom-bar .card-label-title {
  pointer-events: auto !important;
}

/* Full opacity on card hover */
.collection-card:hover .card-bottom-bar {
  opacity: 1;
}

/* Card title in bottom bar */
.card-bottom-bar .card-label-title {
  flex: 1;
  font-size: 16px;
  font-weight: 400;
  color: #fff;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.15));
  line-height: 24px;
  font-family: var(--font-family);
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s ease;
}

/* Card title input for editing */
.card-bottom-bar .card-label-title-input {
  flex: 1;
  font-size: 16px;
  font-weight: 400;
  color: #fff;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.15));
  line-height: 24px;
  font-family: var(--font-family);
  text-align: left;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  padding: 2px 6px;
  outline: none;
  opacity: 1;
  user-select: text;
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  pointer-events: auto !important;
}

/* Show title on card hover */
.collection-card:hover .card-bottom-bar .card-label-title {
  opacity: 1;
}

/* Card icon in bottom bar */
.card-bottom-bar .card-icon {
  position: static;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.15));
}

.card-bottom-bar .card-icon svg {
  width: 24px;
  height: 24px;
  stroke: #fff;
  stroke-width: 2;
  fill: none;
}

/* When card is expanded (overlay/modal) */
.collection-card.expanded {
  position:fixed !important;
  top:0 !important;
  left:0 !important;
  right:0 !important;
  bottom:0 !important;
  width:100vw !important;
  height:100vh !important;
  z-index:9999 !important;
  background:rgba(0,0,0,0.7);
  flex:none;
  min-width:100%;
  cursor:auto;
  display:flex;
  align-items:center;
  justify-content:center;
  transform: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  margin: 0 !important;
}

/* Prevent hover transform when expanded */
.collection-card.expanded:hover {
  transform: none !important;
  box-shadow: none !important;
}

/* Disable gradient border effect when expanded */
.collection-card.expanded::before {
  display: none;
}

/* ===== Expanded Modals ===== */
/* Expanded card background (modal container) */.collection-card.expanded .card-background {
  width: 100%;
  height: 100%;
  max-width: calc(100vw - 64px);
  max-height: calc(100vh - 64px);
  min-width: 320px;
  min-height: 240px;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  background: #fff;
  position: relative;
  overflow: hidden;
}

/* Remove dark gradient overlay when card is expanded */
.collection-card.expanded .card-background::before {
  display: none;
}

/* Expanded card inner should fill the modal */
.collection-card.expanded .card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  top: auto;
  left: auto;
}

/* Hide any thumbnail images when card is expanded (editor is shown) */
.collection-card.expanded .card-inner img,
.collection-card.expanded .card-background img {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  z-index: -1 !important;
}

/* Expanded media modal layout */
.expanded-media-container {
  display:flex;
  width:100%;
  height:100%;
  gap:0;
  align-items:stretch;
}

.expanded-resize-handle {
  position:absolute;
  right:16px;
  bottom:16px;
  width:42px;
  height:42px;
  border-radius:50%;
  border:none;
  background:#f5f5f5;
  box-shadow:0 6px 18px rgba(0,0,0,0.12);
  cursor:nwse-resize;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:18px;
  color:#555;
  transition:background 0.2s;
}
.expanded-resize-handle:hover {
  background:#e2e2e2;
}

/* ===== Media Modal - Left Side (Image Thumbnail) ===== */
.expanded-media-left {
  /* left(media) side: occupy majority of the panel but leave room for notes */
  flex: 0 0 60%;
  max-width: 65%;
  background: #fff;
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
  border-top-left-radius:20px;
  border-bottom-left-radius:20px;
}

.mesh-viewer-canvas {
  width:100%;
  height:100%;
  position:relative;
  background:#0f1116;
}
.mesh-viewer-canvas canvas {
  width:100% !important;
  height:100% !important;
  display:block;
}

/* Image fills the left panel with natural aspect ratio preservation */
.expanded-media-left img {
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
}

/* ===== Media Modal - Right Side (Notes Textarea) ===== */
.expanded-media-right {
  /* notes side takes remaining space and shows a light paper background */
  flex:1 1 auto;
  padding:30px;
  display:flex;
  flex-direction:column;
  position:relative;
  background: #efefef;
  min-width:260px;
  border-top-right-radius:20px;
  border-bottom-right-radius:20px;
}

/* Title in media modal right panel */
.expanded-media-title {
  font-size:24px;
  font-weight:700;
  color:#333;
  margin-bottom:30px;
}

/* Label for notes textarea */
.expanded-media-notes-label {
  font-size:14px;
  font-weight:600;
  color:#666;
  margin-bottom:12px;
}

/* Textarea with paper-line background (visual note-taking aesthetic) */
.expanded-media-notes {
  /* make textarea occupy remaining vertical space reliably */
  display:block;
  width:100%;
  box-sizing:border-box;
  border:0;
  padding:12px 8px 12px 8px;
  font-size:14px;
  color:#222;
  resize:none;
  outline:none;
  line-height:1.8;
  background-color: transparent;
  flex: 1 1 auto;
  min-height:0; /* allow flex child to shrink properly */
  overflow:auto;
  /* subtle paper lines */
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(1.6em - 1px), rgba(0,0,0,0.04) calc(1.6em - 1px), rgba(0,0,0,0.04) 1.6em);
  background-size: 100% 1.6em;
  background-position: left top;
  background-repeat: repeat-y;
}

/* Placeholder text color for notes */
.expanded-media-notes::placeholder {
  color:#bbb;
}

/* Close button in media modal (top-right corner) */
.expanded-media-close {
  position:absolute;
  top:16px;
  right:16px;
  width:36px;
  height:36px;
  background:#f0f0f0;
  border:none;
  border-radius:50%;
  font-size:20px;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  color:#666;
  transition:background 0.2s;
}

.expanded-media-close:hover {
  background:#e0e0e0;
}

/* Expanded code editor modal layout (matches provided mock) */
.expanded-code-container {
  display:flex;
  flex-direction:column;
  width:100%;
  height:100%;
  align-items:stretch;
}

/* ===== Code Editor Modal - Dark Editor Area ===== */
.expanded-code-editor {
  /* dark editor area */
  flex:1 1 auto;
  background:#1e1e2e;
  border-top-left-radius:20px;
  border-top-right-radius:20px;
  overflow:hidden;
  display:flex;
}

/* ===== Code Editor Modal - Light Footer Bar ===== */
.expanded-code-footer {
  /* light footer bar with title and close */
  flex:0 0 64px;
  background:#fafafa;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 18px;
  border-bottom-left-radius:20px;
  border-bottom-right-radius:20px;
  box-shadow: 0 -6px 18px rgba(0,0,0,0.06);
}

/* Title in code editor footer */
.expanded-code-title {
  font-size:18px;
  font-weight:600;
  color:#222;
}

/* Close button in code editor footer (bottom-right) */
.expanded-code-close {
  width:40px;
  height:40px;
  border-radius:50%;
  background:#efefef;
  display:flex;
  align-items:center;
  justify-content:center;
  border:none;
  font-size:18px;
  cursor:pointer;
  color:#444;
}

.expanded-code-close:hover { background:#e0e0e0 }

/* Ensure CodeMirror fills its container and applies dark theme */
.expanded-code-editor .CodeMirror { height:100% !important; width:100% !important; }

/* Hide the small top-left card icon when the code card is expanded */
#card-code.expanded .card-icon { display:none !important; }

/* Dark background for collapsed code card */
#box-code:not(.expanded) { background:#1e1e2e; }
#box-code:not(.expanded) .box-label { color:#fff; }

/* Code card inner should not have gradient background - rely on card component */
.collection-card[data-type="code"] .card-inner {
  background: transparent !important;
}

/* Drag and drop states */
.dragging { opacity:0.5; }
.drag-over { background-color:#e8f4f8 !important; border:2px solid #0d6efd; }

/* ===== Component Utilities ===== */
/* Collection box label and inner content */
.collection-box .box-label { font-weight:600; margin-bottom:8px }
.collection-box .box-inner { flex:1; background:transparent; border-radius:8px; overflow:hidden; display:flex; align-items:center; justify-content:center; }
.collection-box .CodeMirror { height:100%; }

/* Image/video add button (large plus in center) */
.content-add-button { display:flex; align-items:center; justify-content:center; width:100%; height:100%; }
.add-image-btn { width:64px; height:64px; border-radius:50%; background:var(--plus-btn-bg); border:none; font-size:28px; font-weight:700; cursor:pointer; display:grid; place-items:center; padding:0; }
.add-image-btn:hover { background:var(--plus-btn-hover); }

/* ===== Media Preview & Overlay ===== */
/* Image preview in card */
.image-preview { width:100%; height:100%; object-fit:cover; border-radius:8px; display:block; }

/* Media thumbnail and fullscreen overlay */
.media-thumb { width: var(--media-thumb-width); height: var(--media-thumb-height); object-fit:cover; border-radius:8px; cursor:pointer; display:block; }
.media-overlay { position:fixed; left:0; top:0; right:0; bottom:0; background:rgba(0,0,0,0.75); display:flex; align-items:center; justify-content:center; z-index:2000; }
.media-overlay img { max-width:90%; max-height:90%; border-radius:6px; }

/* Play overlay for video thumbnails inside cards */
.video-play-overlay {
  position: absolute;
  width:72px;
  height:72px;
  border-radius:50%;
  background: rgba(0,0,0,0.45);
  color: #fff;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:32px;
  left:50%;
  top:50%;
  transform: translate(-50%,-50%);
  z-index:11;
  pointer-events:none;
}

.video-thumb { display:block; }

/* ===== URL Input Form (Add Media) ===== */
/* Container for URL input modal form */
.image-url-form { display:flex; flex-direction:column; gap:12px; padding:12px; width:100%; }
/* Input field for media URL */
.image-url-form input { padding:8px 12px; border:1px solid #ccc; border-radius:8px; font-size:14px; }
/* Button group layout */
.image-url-form .btn-group { display:flex; gap:8px; }
/* Base button styling */
.image-url-form button { padding:8px 16px; border:none; border-radius:8px; cursor:pointer; font-size:14px; font-weight:600; }
/* Add/submit button (blue primary) */
.image-url-form .btn-add { background:#0d6efd; color:white; }
.image-url-form .btn-add:hover { background:#0b5ed7; }
/* Cancel button (light gray) */
.image-url-form .btn-cancel { background:#e9ecef; color:#333; }
.image-url-form .btn-cancel:hover { background:#dee2e6; }

/* ===============================================
   MODERN HOME PAGE DESIGN (MediaCard Style)
   =============================================== */

/* Background decoration with animated blobs */
.bg-decoration {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.blob {
  position: absolute;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  mix-blend-mode: multiply;
  filter: blur(60px);
  opacity: 0.3;
  animation: blob 7s infinite;
}

.blob-1 {
  top: -160px;
  right: -160px;
  background: #c084fc;
  animation-delay: 0s;
}

.blob-2 {
  bottom: -160px;
  left: -160px;
  background: #93c5fd;
  animation-delay: 2s;
}

.blob-3 {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #f9a8d4;
  animation-delay: 4s;
}

@keyframes blob {
  0%, 100% {
    transform: translate(0, 0) scale(1);
  }
  33% {
    transform: translate(30px, -50px) scale(1.1);
  }
  66% {
    transform: translate(-20px, 20px) scale(0.9);
  }
}

/* Main container */
body {
  min-height: 100vh;
  background: linear-gradient(to bottom right, #f8fafc, #ffffff, #f1f5f9);
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.main-container {
  position: relative;
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px 24px;
  z-index: 1;
}

/* Header Section */
.header-section {
  margin-bottom: 40px;
}

.header-content {
  margin-bottom: 24px;
}

.header-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.header-icon {
  padding: 8px;
  background: linear-gradient(to bottom right, #8b5cf6, #7c3aed);
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-icon svg {
  color: white;
}

.page-title {
  font-size: 28px;
  font-weight: 700;
  color: #111827;
  margin: 0;
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 16px;
  color: #6b7280;
  margin: 0;
  margin-left: 56px;
}

/* Search Section */
.search-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-bar {
  flex: 1;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 14px 16px 14px 48px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  font-size: 15px;
  outline: none;
  transition: all 0.2s ease;
}

.search-input:focus {
  border-color: #a78bfa;
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.1);
}

.filter-button,
.layout-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  font-size: 15px;
  color: #374151;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-button:hover,
.layout-button:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}

.layout-button {
  padding: 14px;
}

/* Add Collection Button (Centered Circular) */
.add-button-container {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.add-collection-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(to bottom right, #7c3aed, #6d28d9);
  color: white;
  border: none;
  box-shadow: 0 8px 16px rgba(124, 58, 237, 0.25);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.add-collection-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 24px rgba(124, 58, 237, 0.4);
}

.add-collection-btn:active {
  transform: scale(1.05);
}

/* Collections Grid (Responsive) */
.collections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  margin-bottom: 40px;
}

@media (min-width: 768px) {
  .collections-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .collections-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Media Card Styles */
.media-card {
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.media-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.media-card-image {
  position: relative;
  aspect-ratio: 4/3;
  overflow: hidden;
  background: #111827;
}

.media-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: all 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.media-card:hover .media-card-img {
  transform: scale(1.1) rotate(1deg);
}

/* Placeholder gradient for collections without images */
.media-card-placeholder {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Dark gradient overlay */
.media-card-gradient-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom right, rgba(0,0,0,0.4), transparent, rgba(0,0,0,0.4));
  opacity: 0.6;
}

/* Media type badges (top-left) */
.media-card-badges {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  z-index: 2;
}

.media-type-badge {
  padding: 8px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.media-card:hover .media-type-badge {
  background: rgba(0, 0, 0, 0.7);
}

/* Bottom info with gradient background */
.media-card-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px;
  background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.6) 60%, transparent 100%);
  z-index: 2;
}

.media-card-title {
  font-size: 18px;
  font-weight: 600;
  color: white;
  margin: 0 0 4px 0;
}

.media-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
}

/* Three-dot menu button (positioned absolutely) */
.media-card-menu {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 0, 0, 0.1);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
  color: #374151;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
  z-index: 10;
  padding: 0;
}

.media-card-menu:hover {
  background: white;
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Stats Dashboard */
.stats-dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 40px;
}

@media (min-width: 640px) {
  .stats-dashboard {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .stats-dashboard {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-card {
  position: relative;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(229, 231, 235, 0.5);
  transition: all 0.3s ease;
}

.stat-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

.stat-card-label {
  font-size: 13px;
  color: #6b7280;
  margin: 0;
}

.stat-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-purple {
  background: linear-gradient(to bottom right, #ede9fe, #ddd6fe);
  color: #7c3aed;
}

.icon-blue {
  background: linear-gradient(to bottom right, #dbeafe, #bfdbfe);
  color: #2563eb;
}

.icon-pink {
  background: linear-gradient(to bottom right, #fce7f3, #fbcfe8);
  color: #db2777;
}

.icon-orange {
  background: linear-gradient(to bottom right, #fed7aa, #fdba74);
  color: #ea580c;
}

.stat-card-value {
  font-size: 28px;
  font-weight: 700;
  color: #111827;
  margin: 0;
}

.stat-card-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.bar-purple {
  background: linear-gradient(to right, #8b5cf6, #7c3aed);
}

.bar-blue {
  background: linear-gradient(to right, #3b82f6, #2563eb);
}

.bar-pink {
  background: linear-gradient(to right, #ec4899, #db2777);
}

.bar-orange {
  background: linear-gradient(to right, #f97316, #ea580c);
}

/* Responsive adjustments */
@media (max-width: 767px) {
  .main-container {
    padding: 24px 16px;
  }

  .page-title {
    font-size: 24px;
  }

  .page-subtitle {
    margin-left: 0;
    margin-top: 4px;
  }

  .header-title-group {
    flex-direction: column;
    align-items: flex-start;
  }

  .search-section {
    flex-direction: column;
  }

  .filter-button,
  .layout-button {
    width: 100%;
    justify-content: center;
  }

  .collections-grid {
    grid-template-columns: 1fr;
  }
}

/* ===============================================
   DARK MONOCHROMATIC THEME (Home Page)
   =============================================== */

body.dark-theme {
  background: #212121 !important;
  min-height: 100vh;
  margin: 0;
  display: flex;
}

body.dark-theme .bg-decoration {
  display: none;
}

/* Left Sidebar */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 72px;
  height: 100vh;
  background: #1e1e1e;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px 0;
  gap: 16px;
  z-index: 100;
}

/* Sidebar Logo */
.sidebar-logo-link {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  max-width: 36px;
  max-height: 36px;
  object-fit: contain;
}

/* Sidebar icon extends btn-icon base class */
.sidebar-icon {
  /* Inherits from .btn-icon - apply both classes in HTML: class="btn-icon sidebar-icon" */
  /* Or use standalone with these overrides: */
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: #3d3d4d;
  border: 1px solid rgba(190, 219, 255, 0.5);
  box-shadow: 0px 0px 0px 1px rgba(190, 219, 255, 0.5), 0px 10px 15px -3px rgba(0, 0, 0, 0.1), 0px 4px 6px -4px rgba(0, 0, 0, 0.1);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  opacity: 0.5;
}

.sidebar-icon:hover {
  opacity: 1;
  transform: scale(1.05);
  box-shadow: 0px 0px 0px 2px rgba(190, 219, 255, 0.7), 0px 10px 15px -3px rgba(0, 0, 0, 0.15), 0px 4px 6px -4px rgba(0, 0, 0, 0.15);
}

.sidebar-icon.active {
  opacity: 1;
}

.sidebar-icon.active:hover {
  transform: scale(1.05);
  box-shadow: 0px 0px 0px 2px rgba(190, 219, 255, 0.7), 0px 10px 15px -3px rgba(0, 0, 0, 0.15), 0px 4px 6px -4px rgba(0, 0, 0, 0.15);
}

/* Main Content Wrapper */
.main-wrapper {
  flex: 1;
  margin-left: 72px;
  padding: 24px 40px;
  display: flex;
  flex-direction: column;
  min-height: fit-content; /* Size to fit all content */
  height: auto;
  overflow-y: auto; /* Show scrollbar when content exceeds viewport */
  overflow-x: hidden; /* Prevent horizontal scroll */
}

/* Dark Theme Header */
body.dark-theme .header-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.back-to-home-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 8px;
  color: #ffffff;
  text-decoration: none;
  transition: background 0.2s;
}

.back-to-home-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.back-to-home-btn svg {
  width: 20px;
  height: 20px;
}

body.dark-theme .user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.1);
}

body.dark-theme .user-name {
  font-size: 18px;
  font-weight: 500;
  color: #ffffff;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Logout button extends btn-ghost base class */
.logout-btn {
  /* Inherits from .btn-ghost - can apply class="btn-ghost logout-btn" in HTML */
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.logout-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}

/* Pitara Logo in Header */
.pitara-logo-link {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.pitara-header-logo {
  height: 32px;
  width: auto;
}

/* Dark Theme Search */
body.dark-theme .search-section {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

body.dark-theme .search-bar {
  flex: 1;
  position: relative;
}

body.dark-theme .search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #6b7280;
  pointer-events: none;
}

body.dark-theme .search-input {
  width: 100%;
  padding: 14px 16px 14px 48px;
  background: #2d2d2d;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  font-size: 15px;
  color: #ffffff;
  outline: none;
  transition: all 0.2s ease;
}

body.dark-theme .search-input::placeholder {
  color: #6b7280;
}

body.dark-theme .search-input:focus {
  border-color: rgba(255, 255, 255, 0.25);
  background: #333333;
}

body.dark-theme .filter-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  background: #2d2d2d;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: #9ca3af;
  cursor: pointer;
  transition: all 0.2s ease;
}

body.dark-theme .filter-button span {
  display: none;
}

body.dark-theme .filter-button:hover {
  background: #333333;
  border-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

/* Dark Theme Collections Grid */
body.dark-theme .collections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 24px;
  flex: 1;
  margin-bottom: 24px;
  min-height: 0;
}

/* Dark Theme Collection Card */
body.dark-theme .home-collection-card {
  --gradient-angle: 135deg;
  aspect-ratio: 4/3;
  border-radius: 16px;
  position: relative;
  cursor: pointer;
  overflow: hidden;
  background: #2d2d2d;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Rainbow gradient border effect for home collection cards */
body.dark-theme .home-collection-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 16px;
  padding: 2px;
  background: linear-gradient(var(--gradient-angle), #ff6b6b, #feca57, #48dbfb, #ff9ff3, #ff6b6b);
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

body.dark-theme .home-collection-card:hover::before {
  opacity: 1;
}

/* Ensure card content is above the gradient border */
body.dark-theme .home-collection-card > * {
  position: relative;
  z-index: 1;
}

/* Inner container to clip content and maintain rounded corners */
body.dark-theme .home-collection-card .card-content-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 16px;
  overflow: hidden;
  background: #2d2d2d;
  z-index: 1;
}

body.dark-theme .home-collection-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

body.dark-theme .collection-preview-grid {
  background: #2d2d2d;
}

body.dark-theme .collection-preview-item {
  background: #3d3d3d;
}

body.dark-theme .collection-card-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.65) 60%, transparent 100%);
  padding: 20px;
  z-index: 2;
}

body.dark-theme .collection-card-name {
  font-size: 18px;
  font-weight: 600;
  color: #ffffff;
}

body.dark-theme .collection-card-count {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
}

body.dark-theme .collection-card-date {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
}

/* Dark Theme Add Collection Card */
body.dark-theme .home-add-card {
  aspect-ratio: 4/3;
  border-radius: 16px;
  background: #3d3d3d;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

body.dark-theme .home-add-card:hover {
  background: #4d4d4d;
}

body.dark-theme .home-add-plus {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #5d5d5d;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  font-size: 24px;
  font-weight: 300;
}

body.dark-theme .home-add-label {
  font-size: 14px;
  color: #9ca3af;
}

/* Dark Theme Collection Card Menu */
body.dark-theme .collection-card-menu {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all 0.2s ease;
}

body.dark-theme .collection-card-menu:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.1);
}

body.dark-theme .collection-menu-dropdown {
  background: #3d3d3d;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-theme .collection-menu-item {
  color: #e5e7eb;
}

body.dark-theme .collection-menu-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

body.dark-theme .collection-menu-item.delete {
  color: #f87171;
}

body.dark-theme .collection-menu-item.delete:hover {
  background: rgba(239, 68, 68, 0.2);
}

/* Dark Theme Stats Bar */
.stats-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px 0;
  margin-bottom: 32px; /* Match filter tabs spacing */
  flex-shrink: 0; /* Prevent stats bar from shrinking */
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 43px;
  padding: 0 20px;
  background: #2d2d2d;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: #9ca3af;
  font-size: 14px;
}

.stat-pill-label {
  color: #6b7280;
}

.stat-pill-value {
  color: #ffffff;
  font-weight: 600;
}

.stat-pill.share-with-you-btn {
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
}

.invitation-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #ef4444;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  animation: badgePulse 0.3s ease-out;
}

.invitation-badge.hidden {
  display: none;
}

@keyframes badgePulse {
  0% { transform: scale(0); }
  70% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.stat-pill.share-with-you-btn:hover {
  background: #3d3d3d;
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.stat-pill.share-with-you-btn.active {
  background: rgba(37, 99, 235, 0.2);
  border-color: rgba(37, 99, 235, 0.5);
  color: #60a5fa;
}

.stat-pill.share-with-you-btn.active .stat-pill-label,
.stat-pill.share-with-you-btn.active span {
  color: #60a5fa;
}

.stat-pill.share-with-you-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Back to collections button in shared view */
.stat-pill.back-to-collections-btn {
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-pill.back-to-collections-btn:hover {
  background: #3d3d3d;
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.stat-pill.back-to-collections-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Shared collections label pill */
.stat-pill.shared-label-pill {
  background: rgba(37, 99, 235, 0.15);
  border-color: rgba(37, 99, 235, 0.3);
}

.stat-pill.shared-label-pill .stat-pill-label {
  color: #60a5fa;
}

.stat-pill.shared-label-pill svg {
  color: #60a5fa;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Responsive for dark theme */
@media (max-width: 768px) {
  .sidebar {
    width: 56px;
    padding: 16px 0;
  }

  .sidebar-icon {
    width: 40px;
    height: 40px;
  }

  .sidebar-logo {
    width: 24px;
    max-width: 24px;
    max-height: 24px;
  }

  .main-wrapper {
    margin-left: 56px;
    width: calc(100% - 56px);
    padding: 16px 20px;
    box-sizing: border-box;
  }

  body.dark-theme .collections-grid {
    grid-template-columns: 1fr;
  }

  .stats-bar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .stat-pill {
    padding: 8px 16px;
    font-size: 13px;
  }
}

/* ===== Collection Page Dark Theme ===== */

/* Collection Page Main Content */
.collection-main-wrapper {
  margin-left: 72px;
  flex: 1;
  min-width: 0;
  width: calc(100% - 72px);
  padding: 24px 32px 48px 32px;
  min-height: 100vh;
  background: #2a2929;
  overflow-x: hidden;
  box-sizing: border-box;
}

/* Dark theme card styling for collection page */
.collection-main-wrapper .collection-card.collection-page-card .card-background {
  background: linear-gradient(180deg, rgba(61, 61, 61, 1) 0%, rgba(33, 33, 33, 1) 100%);
  box-shadow: none;
}

.collection-main-wrapper .collection-card.collection-page-card .card-background::before {
  background: linear-gradient(rgba(0, 0, 0, 0) 31.3%, rgba(0, 0, 0, 0.2) 53.4%, rgba(0, 0, 0, 0.8) 100%);
}

.collection-main-wrapper .collection-card.collection-page-card .card-label-title {
  color: #ffffff;
  font-size: 18px;
  font-family: "Arimo", sans-serif;
  line-height: 27px;
  text-shadow: 0px 4px 16px rgba(0, 0, 0, 0.15);
}

.collection-main-wrapper .collection-card.collection-page-card .card-icon {
  color: #ffffff;
  filter: drop-shadow(0px 4px 16px rgba(0, 0, 0, 0.15));
}

.collection-main-wrapper .collection-card.collection-page-card .card-icon svg {
  stroke: #ffffff;
}

/* Collection Header */
.collection-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  margin-bottom: 24px;
}

.collection-header-left {
  display: flex;
  align-items: center;
  gap: 32px;
  flex: 1;
  min-width: 0;
}

/* Search bar inside header - next to title */
.collection-header-search {
  flex: 1;
  max-width: 850px;
  min-width: 120px;
  margin-right: 24px;
}

.collection-header-search .collection-search-input {
  height: 48px;
}

.collection-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: #3d3d3d;
  text-decoration: none;
  color: #d1d5dc;
  transition: all 0.2s ease;
}

.collection-back-btn:hover {
  background: #4d4d4d;
  color: #ffffff;
}

.collection-back-btn svg {
  width: 20px;
  height: 20px;
}

.collection-title-dark {
  margin: 0;
  font-size: 24px;
  font-family: "Arimo", sans-serif;
  font-weight: 400;
  color: #ffffff;
  line-height: 36px;
  cursor: pointer;
  padding: 4px 12px;
  border-radius: 8px;
  transition: background 0.2s;
}

.collection-title-dark:hover {
  background: rgba(255, 255, 255, 0.08);
}

.collection-title-input-dark {
  font-size: 24px;
  font-family: "Arimo", sans-serif;
  font-weight: 400;
  color: #ffffff;
  background: #3d3d3d;
  border: 2px solid #2563eb;
  border-radius: 8px;
  padding: 4px 12px;
  outline: none;
}

.collection-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.collection-share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: #3d3d3d;
  border: none;
  color: #ffffff;
  cursor: pointer;
  transition: background 0.2s;
  padding: 0;
}

.collection-share-btn:hover {
  background: #4d4d4d;
}

.collection-share-btn svg {
  width: 20px;
  height: 20px;
}

.collection-user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 0 6px;
  height: 48px;
  border-radius: 14px;
  background: #3d3d3d;
  transition: background 0.2s;
}

.collection-user-menu:hover {
  background: #4d4d4d;
}

.collection-signup-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 0 20px;
  border-radius: 14px;
  background: #3d3d3d;
  color: #ffffff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  font-family: "Arimo", sans-serif;
  transition: background 0.2s;
  white-space: nowrap;
}

.collection-signup-btn:hover {
  background: #4d4d4d;
}

.collection-user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  object-fit: cover;
  background: linear-gradient(rgba(74, 85, 101, 1) 0%, rgba(54, 65, 83, 1) 100%);
}

/* Default avatar placeholder when no image */
.collection-user-menu .avatar-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: linear-gradient(rgba(74, 85, 101, 1) 0%, rgba(54, 65, 83, 1) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #d1d5db;
  font-size: 14px;
  font-weight: 600;
}

.dropdown-chevron {
  width: 16px;
  height: 16px;
  color: rgba(153, 161, 175, 1);
  transition: transform 0.2s ease;
}

.collection-user-menu.open .dropdown-chevron {
  transform: rotate(180deg);
}

/* User Dropdown */
.user-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 8px;
  background: #2d2d2d;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  min-width: 160px;
  z-index: 1000;
  overflow: hidden;
}

.user-dropdown.show {
  display: block;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: #d1d5db;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
  text-align: left;
}

.user-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.user-dropdown-item svg {
  flex-shrink: 0;
}

/* User dropdown: Dashboard toggle row (toggle left, label right) */
.user-dropdown-toggle-row {
  cursor: default;
  justify-content: flex-start;
  gap: 12px;
  padding-left: 14px;
  padding-right: 14px;
}
.user-dropdown-toggle-row:hover {
  background: transparent;
  color: #d1d5db;
}
.user-dropdown-toggle-switch {
  position: relative;
  display: inline-block;
  width: 20px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
}
.user-dropdown-toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.user-dropdown-toggle-slider {
  position: absolute;
  inset: 0;
  background: #4b5563;
  border-radius: 16px;
  transition: background 0.2s;
}
.user-dropdown-toggle-slider::before {
  content: '';
  position: absolute;
  height: 12px;
  width: 12px;
  left: 2px;
  bottom: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.user-dropdown-toggle-switch input:checked + .user-dropdown-toggle-slider {
  background: #2563eb;
}
.user-dropdown-toggle-switch input:checked + .user-dropdown-toggle-slider::before {
  transform: translateX(4px);
}

/* AI Usage modal (collection and home) */
.usage-modal-content {
  max-width: 380px;
}
.usage-loading,
.usage-error {
  margin: 0;
  color: rgba(209, 213, 220, 0.8);
  font-size: 14px;
}
.usage-error {
  color: #f87171;
}
.usage-period {
  margin: 0 0 12px;
  font-size: 13px;
  color: rgba(209, 213, 220, 0.7);
}
.usage-bar-wrap {
  margin-bottom: 12px;
}
.usage-bar-track {
  height: 10px;
  background: rgba(61, 61, 61, 1);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 6px;
}
.usage-bar-wrap .usage-bar-fill {
  height: 100%;
  border-radius: 10px;
  transition: width 0.2s;
}
.usage-bar-wrap .usage-bar-fill.low {
  background: #22c55e;
}
.usage-bar-wrap .usage-bar-fill.medium {
  background: #eab308;
}
.usage-bar-wrap .usage-bar-fill.high {
  background: #ef4444;
}
.usage-numbers {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  color: #d1d5dc;
}
.usage-tokens {
  margin: 0 0 8px;
  font-size: 13px;
  color: rgba(209, 213, 220, 0.85);
}
.usage-plan {
  margin: 0 0 4px;
  font-size: 13px;
  color: rgba(209, 213, 220, 0.7);
}
.usage-remaining {
  margin: 0;
  font-size: 13px;
  color: rgba(209, 213, 220, 0.8);
}
.usage-breakdown-wrap {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(61, 61, 61, 1);
}
.usage-breakdown-title {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(209, 213, 220, 0.8);
}
.usage-breakdown-list {
  margin: 0;
  padding-left: 16px;
  font-size: 12px;
  color: rgba(209, 213, 220, 0.85);
  line-height: 1.5;
}
.usage-breakdown-list li {
  margin-bottom: 4px;
}
.usage-breakdown-label {
  display: inline-block;
  min-width: 120px;
}
.usage-breakdown-tokens {
  color: rgba(209, 213, 220, 0.75);
}
.usage-breakdown-cost {
  margin-left: 8px;
  font-variant-numeric: tabular-nums;
}
.usage-pricing-note {
  margin: 8px 0 0;
  font-size: 11px;
  color: rgba(209, 213, 220, 0.55);
}
.usage-note {
  margin: 12px 0 0;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.4;
  color: rgba(209, 213, 220, 0.7);
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
}

/* Add Item Row (search moved to header) + Collapsible Dashboard */
.collection-search-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  margin-bottom: 32px;
  position: relative;
  z-index: 5;
}

/* Dashboard toggle button (collapsed state) - matches collapse button / filter-tab style */
.collection-dashboard-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 43px;
  padding: 0 16px;
  min-width: 40px;
  background: #212121;
  border: 1px solid rgba(61, 61, 61, 1);
  border-radius: 14px;
  color: rgba(153, 161, 175, 1);
  font-size: 14px;
  font-family: "Arimo", sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
  box-sizing: border-box;
}
.collection-dashboard-toggle:hover {
  background: #2a2a2a;
  border-color: rgba(190, 219, 255, 0.5);
  color: #d1d5db;
  box-shadow: 0px 0px 2px 1px rgba(190, 219, 255, 0.7), 0px 10px 15px -3px rgba(0, 0, 0, 0.15), 0px 4px 6px -4px rgba(0, 0, 0, 0.15);
}
.collection-dashboard-toggle .dashboard-chevron {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}
.collection-dashboard-toggle[aria-expanded="true"] .dashboard-chevron {
  transform: rotate(180deg);
}

/* Collapsible dashboard panel - toggle inside panel; collapsed = bar only, expanded = full content */
.collection-dashboard-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0;
  background: #252525;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  overflow: hidden;
  margin-top: 8px;
}
/* Collapsed: panel height comes from content (tab row only when tabpanels max-height 0) */
/* Dashboard disabled by user setting (toggle in user dropdown) */
.collection-dashboard-panel.dashboard-disabled {
  display: none !important;
}

.collection-dashboard-panel.collapsed {
  width: 100%;
  flex-basis: 100%;
  height: 40px;
  min-height: 40px;
  display: flex;
  align-items: flex-start;
  box-sizing: border-box;
}
.collection-dashboard-panel:not(.collapsed) {
  width: 100%;
  flex-basis: 100%;
}
.collection-dashboard-panel {
  transition: none;
}

/* Old header (Dashboard button) hidden – tab row is the single header in both states */
.collection-dashboard-header {
  display: none !important;
}
/* Content (tab row + tabpanels) always visible – header = tab row in both states */
.collection-dashboard-content {
  width: 100%;
  display: block;
}
/* Tabpanels: animate expand/collapse with max-height and opacity; height transition for tab switch */
.collection-dashboard-tabpanels {
  max-height: 500px;
  overflow: hidden;
  opacity: 1;
  visibility: visible;
  transition: max-height 0.35s ease, opacity 0.3s ease, visibility 0.35s ease, height 0.35s ease;
}
/* When Ask tab is active, fix height so messages area can scroll and AI panel stays in view */
.collection-dashboard-tabpanels:has(#dashboardPanelAsk.active) {
  height: 420px;
}
/* When collapsed: tabpanels shrink to invisible (no height, no visibility) */
.collection-dashboard-panel.collapsed .collection-dashboard-tabpanels {
  max-height: 0;
  opacity: 0;
  visibility: hidden;
  padding: 0;
  margin: 0;
  min-height: 0;
  transition: max-height 0.35s ease, opacity 0.3s ease, visibility 0.35s ease, padding 0.35s ease, margin 0.35s ease;
}

/* Expanded: tab row = tabs (left) + collapse button (right) */
.collection-dashboard-tab-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 40px;
  min-height: 30px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
  box-sizing: border-box;
}
.collection-dashboard-tabs {
  display: flex;
  gap: 4px;
  align-items: center;
}
.collection-dashboard-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: rgba(209, 213, 220, 0.8);
  font-size: 14px;
  font-family: "Arimo", sans-serif;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  margin-bottom: -1px;
}
.collection-dashboard-tab .dashboard-tab-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.collection-dashboard-tab .dashboard-tab-icon svg {
  width: 16px;
  height: 16px;
  color: inherit;
}
.collection-dashboard-tab:hover {
  color: #d1d5dc;
}
.collection-dashboard-tab.active {
  color: #ffffff;
  border-bottom-color: #2563eb;
}
/* When collapsed: no blue bar under active tab */
.collection-dashboard-panel.collapsed .collection-dashboard-tab.active {
  border-bottom-color: transparent;
}
/* Collapse/expand button – icon only; visible in both states; chevron flips by state */
.collection-dashboard-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: rgba(153, 161, 175, 1);
  cursor: pointer;
  transition: color 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
  flex-shrink: 0;
  box-sizing: border-box;
}
.collection-dashboard-collapse-btn:hover {
  color: rgba(190, 219, 255, 1);
  filter: drop-shadow(0 0 6px rgba(59, 130, 246, 0.8)) drop-shadow(0 0 12px rgba(59, 130, 246, 0.5));
}
.collection-dashboard-collapse-btn:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.8);
  outline-offset: 2px;
}
.collection-dashboard-collapse-btn svg,
.collection-dashboard-collapse-btn .dashboard-collapse-chevron {
  width: 20px;
  height: 20px;
  color: inherit;
  transition: transform 0.2s ease;
}
/* Expanded: chevron up (collapse); collapsed: chevron down (expand) */
.collection-dashboard-collapse-btn[aria-expanded="true"] .dashboard-collapse-chevron {
  transform: rotate(0deg);
}
.collection-dashboard-collapse-btn[aria-expanded="false"] .dashboard-collapse-chevron {
  transform: rotate(180deg);
}
.collection-dashboard-tabpanels {
  padding: 20px;
  min-height: 180px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}
.collection-dashboard-tabpanel {
  display: none;
  min-height: 140px;
  box-sizing: border-box;
}
.collection-dashboard-tabpanel.active {
  display: block;
}
/* Ask tab: constrain height so messages scroll and AI panel stays in view */
#dashboardPanelAsk.collection-dashboard-tabpanel.active {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}
.collection-dashboard-placeholder {
  margin: 0;
  color: rgba(209, 213, 220, 0.6);
  font-size: 14px;
}
.collection-dashboard-placeholder.streamed-text {
  white-space: pre-wrap;
  word-break: break-word;
}

/* Error message shown when streaming fails mid-response */
.stream-error {
  margin-top: 0.75em;
  padding: 0.5em;
  color: var(--color-error, #ef4444);
  font-size: 0.9em;
  border-left: 3px solid var(--color-error, #ef4444);
  background: rgba(239, 68, 68, 0.08);
}
.collection-dashboard-loading {
  margin: 0;
  color: rgba(209, 213, 220, 0.7);
  font-size: 14px;
}
.collection-dashboard-list {
  margin: 0;
  padding-left: 20px;
  list-style: disc;
  color: rgba(209, 213, 220, 0.95);
  font-size: 14px;
  line-height: 1.5;
}
.collection-dashboard-list li {
  margin-bottom: 6px;
}

/* Refresh info - cache/digest/token breakdown */
.collection-dashboard-info {
  margin: 12px 0 0;
  font-size: 12px;
  color: rgba(209, 213, 220, 0.55);
}

.collection-dashboard-refresh-info {
  margin-top: 12px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  color: rgba(209, 213, 220, 0.75);
  font-size: 12px;
  line-height: 1.4;
}

/* Ask tab - AI assistant component wrapper */
.collection-dashboard-ask-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 0;
  overflow: hidden;
}
.collection-dashboard-ask-messages {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 0;
  overflow-x: hidden;
}

/* Legacy Ask tab (replaced by AI-assistant component) */
.collection-dashboard-ask {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}
.collection-dashboard-ask-input {
  flex: 1;
  min-height: 80px;
  padding: 12px 16px;
  background: #212121;
  border: 1px solid rgba(61, 61, 61, 1);
  border-radius: 12px;
  color: #ffffff;
  font-size: 14px;
  font-family: "Arimo", sans-serif;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}
.collection-dashboard-ask-input::placeholder {
  color: rgba(106, 114, 130, 1);
}
.collection-dashboard-ask-input:focus {
  border-color: rgba(99, 102, 241, 0.6);
}
.collection-dashboard-ask-send {
  flex-shrink: 0;
  height: 44px;
  padding: 0 20px;
  background: #6366f1;
  border: none;
  border-radius: 12px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 500;
  font-family: "Arimo", sans-serif;
  cursor: pointer;
  transition: background 0.2s;
}
.collection-dashboard-ask-send:hover {
  background: #5558e3;
}
.collection-dashboard-ask-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.collection-dashboard-ask-result {
  margin-top: 12px;
  padding: 12px 16px;
  background: #212121;
  border: 1px solid rgba(61, 61, 61, 1);
  border-radius: 12px;
  color: rgba(209, 213, 220, 0.95);
  font-size: 14px;
  line-height: 1.5;
}
.collection-dashboard-answer {
  white-space: pre-wrap;
  word-break: break-word;
}
.collection-dashboard-error {
  margin: 0;
  color: #f87171;
  font-size: 14px;
}

.collection-search-bar {
  width: 672px;
  max-width: 100%;
  min-width: 50px;
  position: relative;
  flex-shrink: 1;
  flex: 1; /* Allow it to grow in flex containers like search-section */
}

.collection-search-bar .search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(106, 114, 130, 1);
  pointer-events: none;
  width: 20px;
  height: 20px;
}

.collection-search-input {
  width: 100%;
  height: 49px;
  padding: 12px 16px 12px 48px;
  background: #212121;
  border: 1px solid rgba(61, 61, 61, 1);
  border-radius: 14px;
  font-size: 16px;
  color: #ffffff;
  outline: none;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.collection-search-input::placeholder {
  color: rgba(106, 114, 130, 1);
}

.collection-search-input:focus {
  border-color: rgba(255, 255, 255, 0.25);
  background: #2a2a2a;
}

/* Add Item Button Wrapper */
.collection-add-wrapper {
  position: relative;
  flex-shrink: 0;
}

/* Add Item Button - New Design */
.collection-add-item-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  padding: 2px 20px 2px 22px;
  background: rgb(54, 65, 83);
  border: 2px solid transparent;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  position: relative;
  z-index: 10;
}

.collection-add-item-btn:hover {
  background: rgb(64, 75, 93);
  border-color: rgba(74, 85, 101, 0.5);
}

.collection-add-item-btn.drag-over {
  background: rgb(74, 85, 103);
  border-color: rgb(99, 179, 237);
  box-shadow: 0 0 12px rgba(99, 179, 237, 0.4);
}

.collection-add-item-btn .add-item-plus-icon {
  flex-shrink: 0;
}

.collection-add-item-btn .add-item-text-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.collection-add-item-btn .add-item-main-text {
  font-size: 14px;
  font-family: "Arimo", sans-serif;
  color: rgb(209, 213, 220);
  line-height: 20px;
  text-align: left;
}

.collection-add-item-btn .add-item-sub-text {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-family: "Arimo", sans-serif;
  color: rgb(106, 114, 130);
  line-height: 16px;
}

.collection-add-item-btn .add-item-sub-text svg {
  flex-shrink: 0;
}

/* Animated stroke overlay for empty collections */
.add-item-stroke-animation {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 1;
}

.add-item-stroke-animation path {
  transition: opacity 0.1s ease-out;
}

/* Table cell borders - set to zero */
td {
  border: 0 !important;
}

/* Add Dropdown */
.collection-add-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 8px;
  background: #2d2d2d;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  min-width: 180px;
  z-index: 1000;
  overflow: hidden;
}

.collection-add-dropdown.show {
  display: block;
}

.collection-dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: #d1d5db;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
  text-align: left;
}

.collection-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.collection-dropdown-item + .collection-dropdown-item {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Filter Tabs (Add Item button is first child, then filter tabs) */
.collection-filter-tabs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 32px;
  flex-wrap: wrap;
  overflow: visible; /* Allow glow effects to show */
}

.collection-filter-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 43px;
  padding: 0 16px;
  background: #212121;
  border: 1px solid rgba(61, 61, 61, 1);
  border-radius: 14px;
  color: rgba(153, 161, 175, 1);
  font-size: 14px;
  font-family: "Arimo", sans-serif;
  line-height: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.collection-filter-tab:hover {
  background: #2a2a2a;
  border-color: rgba(190, 219, 255, 0.5);
  color: #d1d5db;
  box-shadow: 0px 0px 2px 1px rgba(190, 219, 255, 0.7), 0px 10px 15px -3px rgba(0, 0, 0, 0.15), 0px 4px 6px -4px rgba(0, 0, 0, 0.15);
}

.collection-filter-tab.active {
  background: #3d3d3d;
  border-color: rgba(74, 85, 101, 1);
  color: rgba(243, 244, 246, 1);
}

.collection-filter-tab.active:hover {
  background: #3d3d3d;
  border-color: rgba(74, 85, 101, 1);
  color: rgba(243, 244, 246, 1);
  box-shadow: none;
}

.collection-filter-tab .filter-tab-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.collection-filter-tab svg,
.collection-filter-tab .filter-tab-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  /* SVG inherits color from parent text via currentColor */
  color: inherit;
}

/* Icon-only mode: smaller buttons when text is hidden */
.collection-filter-tab.icon-only {
  padding: 0 12px;
  min-width: 40px;
  justify-content: center;
}

.collection-filter-tab.icon-only .filter-tab-icon-wrapper {
  margin: 0;
}

/* Collection Cards Grid (Dark Theme) - Masonry Layout */
.collection-cards-grid-dark {
  position: relative;
  width: 100%;
  box-sizing: border-box;
  min-height: 200px;
  /* Fallback flex layout before masonry is initialized */
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 16px;
}

/* Cards inside the masonry grid - initial state with flex layout fallback */
.collection-cards-grid-dark .collection-card.collection-page-card {
  width: 280px;
  box-sizing: border-box;
  transition: transform 0.26s ease, box-shadow 0.26s ease, opacity 0.3s ease;
  flex-shrink: 0;
}

/* Once masonry-grid.js adds the container class, switch to absolute positioning */
.collection-cards-grid-dark.masonry-grid-container {
  display: block;
  position: relative;
  margin-top: 32px;
  clear: both;
}

.collection-cards-grid-dark.masonry-grid-container .collection-card.collection-page-card {
  position: absolute;
  transition: transform 0.26s ease, box-shadow 0.26s ease, left 0.3s ease, top 0.3s ease, opacity 0.3s ease;
}

.collection-cards-grid-dark .collection-card.collection-page-card.dragging {
  transition: none;
  transform: scale(1.02);
  z-index: 1000;
}

/* Collection Card (Dark Theme - Figma Style) */
.collection-card-dark {
  --gradient-angle: 135deg;
  position: relative;
  width: 288px;
  height: 216px;
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Rainbow gradient border effect */
.collection-card-dark::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 16px;
  padding: 2px;
  background: linear-gradient(var(--gradient-angle), #ff6b6b, #feca57, #48dbfb, #ff9ff3, #ff6b6b);
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.collection-card-dark:hover::before {
  opacity: 1;
}

.collection-card-dark:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

/* Card inner content */
.collection-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(rgba(61, 61, 61, 1) 0%, rgba(33, 33, 33, 1) 100%);
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Card with image */
.collection-card-dark.has-image .collection-card-inner {
  background: rgb(3, 7, 18);
}

.collection-card-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Card type icon (for non-image cards like code) */
.collection-card-type-icon {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(74, 85, 101, 1);
}

.collection-card-type-icon svg {
  width: 64px;
  height: 64px;
}

/* Card gradient overlay */
/* Collection card overlay - positioned at bottom */
.collection-card-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.6) 60%, transparent 100%);
  padding: 16px;
  color: white;
  z-index: 2;
  pointer-events: none;
}

/* Card bottom content */
.collection-card-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px;
  z-index: 3;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}

.collection-card-title {
  font-size: 18px;
  font-family: "Arimo", sans-serif;
  font-weight: 400;
  color: #ffffff;
  line-height: 27px;
  text-shadow: 0px 4px 16px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  flex: 1;
  margin-right: 8px;
}

/* AI indicator icon */
.collection-card-ai-icon {
  width: 24px;
  height: 24px;
  color: rgba(255, 255, 255, 1);
  flex-shrink: 0;
  filter: drop-shadow(0px 4px 16px rgba(0, 0, 0, 0.15));
}

/* ===== Reusable Modal Styles ===== */
/* Standard modal overlay - used by all modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

/* Standard modal container - base styles */
.modal-container {
  background: #2a2a2a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.3s ease;
  position: relative;
  overflow: hidden;
}

/* Note: fadeIn and slideUp animations are already defined earlier in this file */

/* Collection Modal Styles */
.collection-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

.collection-modal-overlay.show {
  display: flex;
}

.collection-modal-content {
  background: #2d2d2d;
  border-radius: 16px;
  padding: 24px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.collection-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.collection-modal-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: #ffffff;
}

/* Image-preview-style close button (used in usage modal and image previewer) */
.image-preview-modal-close {
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.6);
  transition: color 0.2s;
}
.image-preview-modal-close:hover {
  color: #fff;
}

.collection-modal-body .form-group {
  margin-bottom: 16px;
}

.collection-modal-body .form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: #d1d5db;
}

.collection-modal-input {
  width: 100%;
  padding: 12px;
  background: #1e1e1e;
  border: 1px solid #3d3d3d;
  border-radius: 8px;
  font-size: 14px;
  color: #ffffff;
  outline: none;
  transition: border-color 0.2s;
}

.collection-modal-input:focus {
  border-color: #2563eb;
}

.collection-modal-input::placeholder {
  color: #6b7280;
}

/* Single column card layout - prevent overlapping */
@media (max-width: 600px) and (min-width: 320px) {
  .collection-search-row {
    margin-bottom: 48px;
  }

  .collection-cards-grid-dark {
    margin-top: 24px;
    gap: 20px;
  }

  .collection-cards-grid-dark .collection-card.collection-page-card {
    margin-bottom: 16px;
  }
}

/* Responsive for Collection Page */
@media (max-width: 768px) {
  .collection-sidebar {
    width: 56px;
    padding: 16px 0;
  }

  .collection-main-wrapper {
    margin-left: 56px;
    width: calc(100% - 56px);
    flex: 1;
    min-width: 0;
    padding: 16px 20px 32px 20px;
  }

  .collection-search-row {
    flex-direction: row;
    align-items: center;
    gap: 12px;
  }

  .collection-search-bar {
    max-width: none;
    min-width: 50px;
    flex: 1 1 50px;
  }

  .collection-filter-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 8px;
  }
}

/* Home Squares Grid Layout */
#homeSquares {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  box-sizing: border-box;
  flex: 1 1 auto; /* Allow grid to grow and shrink within flex container */
  min-height: 0; /* Allow grid to shrink below content size if needed */
}

/* Ensure proper grid behavior on medium screens */
@media (max-width: 700px) {
  #homeSquares {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
  }
}

/* Ensure cards don't overlap */
#homeSquares .home-collection-card,
#homeSquares .home-add-card {
  min-width: 0;
  max-width: 100%;
  width: 100%;
  position: relative;
}

/* Add Collection card should be visible above others */
#homeSquares .home-add-card {
  z-index: 10;
}

/* Responsive layout for narrow screens - single column */
@media (max-width: 600px) and (min-width: 320px) {
  #homeSquares {
    grid-template-columns: 1fr !important;
    gap: 20px;
    padding: 16px;
    margin-bottom: 24px; /* Add bottom margin to prevent overlap */
  }

  #homeSquares .home-collection-card,
  #homeSquares .home-add-card {
    margin-bottom: 16px;
  }
}

/* Very narrow screens - ensure single column */
@media (max-width: 360px) {
  #homeSquares {
    grid-template-columns: 1fr !important;
    gap: 16px;
    padding: 12px;
  }
}

/* Responsive adjustments for homeSquares */
@media (max-width: 768px) {
  #homeSquares {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    padding: 16px;
  }
}

/* Masonry grid on mobile uses single column - handled by JS */

/* ===============================================
   AI ASSISTANT SIDEBAR - RESPONSIVE DESIGN
   =============================================== */

/* Base styles for AI Assistant Sidebar (desktop default) */
.ai-assistant-sidebar {
  position: relative;
  transition: width 0.3s ease, min-width 0.3s ease, transform 0.3s ease;
}

  /* Desktop styles are set inline in JavaScript */
  /* Mobile overrides are defined below in media queries */

/* Mobile Design: Convert sidebar to full-screen overlay */
@media (max-width: 767px) {
  /* When sidebar is visible, make it full-screen overlay */
  .ai-assistant-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    min-width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    z-index: 10000 !important; /* Above everything else */
    border-left: none !important;
    transform: translateX(0);
    background: #1e1e1e; /* Dark background for mobile */
  }

  /* Slide in animation when opening */
  .ai-assistant-sidebar:not([data-collapsed="true"]) {
    animation: slideInFromRight 0.3s ease-out;
  }

  @keyframes slideInFromRight {
    from {
      transform: translateX(100%);
      opacity: 0;
    }
    to {
      transform: translateX(0);
      opacity: 1;
    }
  }

  /* When collapsed on mobile, hide completely */
  .ai-assistant-sidebar[data-collapsed="true"] {
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
  }

  /* Content area adjustments for mobile */
  .ai-sidebar-content {
    padding: 16px !important; /* Reduced padding on mobile */
    gap: 16px !important;
    /* Ensure content is scrollable */
    -webkit-overflow-scrolling: touch;
  }

  /* Mobile-specific collapsed indicator button */
  .ai-sidebar-collapsed-indicator {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    top: auto !important;
    width: 56px !important; /* Larger touch target */
    height: 56px !important;
    border-radius: 50% !important; /* Circular on mobile */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
    z-index: 9999 !important; /* Below sidebar when open, above when closed */
    opacity: 1 !important; /* Always visible on mobile when collapsed */
    background: #2563eb !important; /* More prominent color */
    border: none !important;
  }

  /* Floating action button style for mobile */
  .ai-sidebar-collapsed-indicator:hover,
  .ai-sidebar-collapsed-indicator:active {
    transform: scale(1.1) !important;
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.5) !important;
    background: #1d4ed8 !important;
  }

  /* Ensure header is properly sized on mobile */
  .ai-assistant-sidebar .ai-assistant-header {
    padding: 16px !important;
    min-height: 56px !important; /* Standard mobile header height */
  }

  /* Adjust AI panel footer for mobile */
  .ai-assistant-sidebar .ai-assistant-panel {
    padding: 16px !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
  }

  /* Mobile input adjustments */
  .ai-assistant-sidebar .ai-assistant-input-row {
    gap: 8px !important;
  }

  .ai-assistant-sidebar textarea,
  .ai-assistant-sidebar input {
    font-size: 16px !important; /* Prevent zoom on iOS */
    padding: 12px !important;
    min-height: 44px !important; /* Touch target size */
  }

  /* Model selector adjustments for mobile */
  .ai-assistant-sidebar select {
    font-size: 14px !important;
    padding: 10px 12px !important;
    min-height: 44px !important; /* Touch target */
  }

  /* Buttons should be touch-friendly */
  .ai-assistant-sidebar button {
    min-height: 44px !important;
    min-width: 44px !important;
    padding: 10px 16px !important;
  }

  /* Backdrop/overlay when sidebar is open on mobile (optional) */
  .ai-assistant-sidebar::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .ai-assistant-sidebar:not([data-collapsed="true"])::before {
    opacity: 1;
  }

  /* Disable resize handle on mobile */
  .ai-assistant-sidebar .resize-handle {
    display: none !important;
  }

  /* Message bubbles adjustments for mobile */
  .ai-assistant-sidebar .ai-message {
    padding: 12px !important;
    margin-bottom: 12px !important;
    font-size: 14px !important;
    line-height: 1.6 !important;
  }

  /* Code blocks in messages */
  .ai-assistant-sidebar pre,
  .ai-assistant-sidebar code {
    font-size: 12px !important;
    padding: 8px !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Image in messages */
  .ai-assistant-sidebar img {
    max-width: 100% !important;
    height: auto !important;
    border-radius: 8px !important;
  }
}

/* Tablet adjustments (640px - 767px) */
@media (min-width: 640px) and (max-width: 767px) {
  .ai-assistant-sidebar {
    /* Can use slide-in panel instead of full-screen on tablet */
    width: 480px !important;
    max-width: 480px !important;
    left: auto !important;
    right: 0 !important;
    border-left: 1px solid rgba(255, 255, 255, 0.1) !important;
  }

  .ai-assistant-sidebar[data-collapsed="true"] {
    transform: translateX(100%);
  }

  .ai-sidebar-collapsed-indicator {
    right: 24px !important;
    bottom: 24px !important;
  }
}

/* Small mobile devices (320px - 480px) */
@media (max-width: 480px) {
  .ai-sidebar-content {
    padding: 12px !important;
    gap: 12px !important;
  }

  .ai-assistant-sidebar .ai-assistant-header {
    padding: 12px 16px !important;
  }

  .ai-assistant-sidebar .ai-assistant-panel {
    padding: 12px !important;
  }

  /* Smaller collapsed indicator on very small screens */
  .ai-sidebar-collapsed-indicator {
    width: 48px !important;
    height: 48px !important;
    bottom: 16px !important;
    right: 16px !important;
  }

  .ai-sidebar-collapsed-indicator svg {
    width: 20px !important;
    height: 20px !important;
  }
}

/* Landscape mobile orientation */
@media (max-width: 767px) and (orientation: landscape) {
  .ai-assistant-sidebar {
    /* Full width but shorter height in landscape */
    height: 100vh !important;
  }

  .ai-assistant-sidebar .ai-assistant-header {
    min-height: 48px !important;
    padding: 12px 16px !important;
  }

  .ai-sidebar-content {
    padding: 12px !important;
  }

  .ai-assistant-sidebar .ai-assistant-panel {
    padding: 12px !important;
  }
}

/* ===== Reusable Section Label Styles ===== */

/**
 * Section Label - Light weight display label
 * Used for section headers and labels that need a lightweight, prominent appearance
 * Example: "Organize board", section titles, etc.
 */
.section-label {
  font-family: "Arimo", sans-serif;
  font-size: 24px;
  font-weight: 200;
  color: #ffffff;
}

/* Dark theme variant if needed */
.section-label-dark {
  font-family: "Arimo", sans-serif;
  font-size: 24px;
  font-weight: 200;
  color: #d1d5dc;
}

/* ===== Block Editor Link Tooltip ===== */

.block-editor-link-tooltip {
  animation: linkTooltipFadeIn 0.15s ease;
}

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

.link-tooltip-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #e5e7eb;
  max-width: 220px;
}

.link-tooltip-title svg {
  color: #9ca3af;
  flex-shrink: 0;
}

.link-tooltip-title-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
}

.link-tooltip-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

.link-tooltip-btn {
  background: transparent;
  border: none;
  color: #9ca3af;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.link-tooltip-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.link-tooltip-open:hover {
  color: #60a5fa;
}

.link-tooltip-copy:hover {
  color: #4ade80;
}

.link-tooltip-remove:hover {
  color: #f87171;
}



