/* ==================== INSTANCEGRAM - Instagram-inspired Design ==================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Light mode (Instagram-inspired) */
  --bg-primary: #fafafa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f5f5f5;
  --border-color: #dbdbdb;
  --border-light: #efefef;
  --text-primary: #262626;
  --text-secondary: #8e8e8e;
  --text-link: #00376b;
  --accent: #0095f6;
  --accent-hover: #1877f2;
  --error: #ed4956;
  --success: #58c322;
  --warning: #ff9800;
  --gradient-start: #833ab4;
  --gradient-mid: #fd1d1d;
  --gradient-end: #fcb045;
  --shadow: rgba(0, 0, 0, 0.1);
  --overlay: rgba(0, 0, 0, 0.65);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

/* ==================== HEADER / NAV BAR ==================== */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.navbar-content {
  width: 100%;
  max-width: 975px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 24px;
  font-weight: 500;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: linear-gradient(45deg, var(--gradient-start), var(--gradient-mid), var(--gradient-end));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo svg {
  width: 28px;
  height: 28px;
}

/* Navbar Logo Styles */
.navbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.navbar-logo-icon {
  width: 28px;
  height: 28px;
}

.navbar-logo-text {
  font-family: 'Cookie', cursive;
  font-size: 28px;
  color: var(--text-primary);
  margin-top: 4px;
}

.nav-actions,
.navbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.nav-btn:hover {
  background: var(--bg-tertiary);
}

.nav-btn svg {
  width: 24px;
  height: 24px;
}

.files-loading-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 4px 10px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  animation: fadeIn 0.2s ease;
}

.files-loading-indicator.hidden {
  display: none;
}

.files-loading-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
  margin-top: 60px;
  min-height: calc(100vh - 60px);
}

/* ==================== SEARCH PAGE ==================== */
.search-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 60px);
  padding: 40px 20px;
  background: var(--bg-primary);
}

.search-page.hidden {
  display: none;
}

.search-container {
  text-align: center;
  max-width: 400px;
  width: 100%;
}

/* Search Brand (main page logo area) */
.search-brand {
  margin-bottom: 24px;
}

.search-brand-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
}

.search-brand-icon img {
  width: 100%;
  height: 100%;
}

.search-brand-title {
  font-family: 'Cookie', cursive;
  font-size: 52px;
  font-weight: 400;
  color: var(--text-primary);
  line-height: 1;
}

/* Search Box */
.search-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
}

.search-input-wrapper {
  position: relative;
  margin-bottom: 12px;
}

.search-input {
  width: 100%;
  padding: 12px 12px 12px 40px;
  font-size: 14px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  transition: border-color 0.2s, background 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: var(--text-secondary);
  background: var(--bg-secondary);
}

.search-input::placeholder {
  color: var(--text-secondary);
}

.search-input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
  pointer-events: none;
}

/* Search Actions */
.search-actions {
  display: flex;
  gap: 8px;
}

.search-btn {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.search-btn.primary {
  flex: 1;
  background: var(--accent);
  color: white;
}

.search-btn.primary:hover {
  background: var(--accent-hover);
}

.search-btn.secondary {
  width: 44px;
  height: 44px;
  padding: 0;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.search-btn.secondary:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

.search-btn.secondary.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.search-btn.secondary svg {
  width: 20px;
  height: 20px;
}

.search-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Scope Indicator */
.scope-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  padding: 8px 12px;
  background: rgba(0, 149, 246, 0.1);
  border-radius: 6px;
  font-size: 12px;
  color: var(--accent);
}

.scope-indicator.hidden {
  display: none;
}

.scope-indicator svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.scope-indicator-clear {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.7;
}

.scope-indicator-clear:hover {
  opacity: 1;
}

/* Legacy styles - keep for compatibility */
.search-hint {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

.search-examples {
  margin-top: 32px;
  padding-top: 32px;
  border-top: 1px solid var(--border-color);
}

.search-examples-title {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.example-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.example-link {
  font-size: 13px;
  color: var(--text-link);
  cursor: pointer;
  text-decoration: none;
}

.example-link:hover {
  text-decoration: underline;
}

/* ==================== LOADING STATE ==================== */
.loading-page {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 60px);
  padding: 40px 20px;
  background: var(--bg-primary);
}

.loading-page.visible {
  display: flex;
}

.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.loading-logo {
  width: 80px;
  height: 80px;
  margin-bottom: 32px;
  animation: logoBreathing 1.5s ease-in-out infinite;
}

.loading-logo img {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 0 transparent);
  animation: logoGlow 1.5s ease-in-out infinite;
}

@keyframes logoBreathing {
  0%, 100% { 
    transform: scale(1);
  }
  50% { 
    transform: scale(1.1);
  }
}

@keyframes logoGlow {
  0%, 100% { 
    filter: drop-shadow(0 0 8px rgba(131, 58, 180, 0.3));
  }
  50% { 
    filter: drop-shadow(0 0 20px rgba(131, 58, 180, 0.6)) drop-shadow(0 0 40px rgba(253, 29, 29, 0.3));
  }
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.loading-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.loading-subtext {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  min-height: 16px;
}

.loading-progress-bar {
  width: 200px;
  height: 3px;
  background: var(--border-color);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}

.loading-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #833ab4, #fd1d1d, #fcb045);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* ==================== PROFILE PAGE (Component View) ==================== */
.profile-page {
  display: none;
  max-width: 975px;
  margin: 0 auto;
  padding: 90px 20px 30px;
}

.profile-page.visible {
  display: block;
}

/* Profile Header */
.profile-header {
  display: flex;
  gap: 80px;
  padding-bottom: 44px;
  border-bottom: 1px solid var(--border-color);
}

.profile-avatar {
  flex-shrink: 0;
}

.avatar-wrapper {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  padding: 3px;
  background: linear-gradient(45deg, var(--gradient-start), var(--gradient-mid), var(--gradient-end));
}

.avatar-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--bg-secondary);
  padding: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: background-color 0.2s ease;
}

.avatar-inner img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.avatar-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border-radius: 50%;
  color: var(--text-secondary);
}

.profile-info {
  flex: 1;
}

.profile-title-row {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.profile-name {
  font-size: 20px;
  font-weight: 400;
}

.profile-type-badge {
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 4px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  text-transform: uppercase;
}

.profile-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.profile-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 16px;
  min-width: 140px;
  height: 36px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  box-sizing: border-box;
}

.profile-btn .btn-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  vertical-align: middle;
}

.profile-btn span {
  line-height: 36px;
  display: inline-flex;
  align-items: center;
}

.profile-btn-primary {
  background: var(--accent);
  color: white;
  border: none;
}

.profile-btn-primary:hover {
  background: var(--accent-hover);
}

.profile-btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.profile-btn-secondary:hover {
  background: var(--border-color);
}

/* Stats Row */
.profile-stats {
  display: flex;
  gap: 40px;
  margin-bottom: 20px;
}

.profile-stat {
  font-size: 16px;
}

.profile-stat-value {
  font-weight: 600;
}

.profile-stat-label {
  color: var(--text-primary);
}

/* Profile Bio / Description */
.profile-bio {
  font-size: 14px;
  margin-bottom: 8px;
}

.profile-bio-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.profile-bio-text {
  color: var(--text-primary);
}

/* ==================== VARIANTS SECTION (Stories-like) ==================== */
.variants-section {
  padding: 20px 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 0;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
}

.variants-scroll {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding: 8px;
  margin: -8px;
  margin-bottom: 0;
  padding-bottom: 16px;
  scrollbar-width: thin;
}

.variant-item {
  flex-shrink: 0;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s ease;
  position: relative;
}

.variant-item:hover {
  transform: scale(1.05);
  z-index: 10;
}

.variant-item:active {
  transform: scale(0.98);
}

.variant-thumb-wrapper {
  width: 77px;
  height: 77px;
  border-radius: 50%;
  padding: 3px;
  background: var(--border-color);
  margin-bottom: 8px;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.variant-item:hover .variant-thumb-wrapper {
  background: linear-gradient(45deg, var(--gradient-start), var(--gradient-mid), var(--gradient-end));
  box-shadow: 0 4px 12px rgba(131, 58, 180, 0.3);
}

.variant-thumb {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--bg-secondary);
  padding: 2px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

.variant-thumb img {
  width: calc(100% - 4px);
  height: calc(100% - 4px);
  object-fit: contain;
  border-radius: 50%;
}

/* Adaptive background for transparent variant images */
.variant-thumb img.adaptive-bg-image {
  background: inherit;
}

.variant-name {
  font-size: 12px;
  color: var(--text-primary);
  max-width: 77px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Floating tooltip for variant name (appended to body via JS) */
.variant-tooltip {
  position: fixed;
  background: var(--text-primary);
  color: var(--bg-secondary);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 10000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.variant-tooltip.visible {
  opacity: 1;
}

.variant-tooltip::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 100%;
  border: 6px solid transparent;
  border-top-color: var(--text-primary);
}

/* ==================== PROPERTIES SECTION (Bio-style) ==================== */
.properties-section {
  padding: 16px 0 16px;
  margin-bottom: 0;
}

.section-header-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.section-header-toggle:hover {
  opacity: 0.8;
}

.section-header-toggle .section-title {
  margin-bottom: 0;
}

.section-toggle-count {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 600;
  line-height: 1;
}

.section-toggle-icon {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
  margin-left: auto;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.properties-section.collapsed .section-toggle-icon {
  transform: rotate(-90deg);
}

.properties-section.collapsed .properties-container {
  display: none;
}

.properties-section .properties-container {
  margin-top: 12px;
}

.properties-section .section-title {
  margin-bottom: 0px;
}

.properties-container {
  /* Container for bio-style properties */
  width: 100%;
}

.properties-bio {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.property-group {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  overflow: hidden;
}

.property-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-light);
}

.property-type-icon {
  font-size: 14px;
  color: var(--accent);
  width: 20px;
  text-align: center;
}

.property-type-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.property-type-count {
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-primary);
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: auto;
}

.property-group-items {
  padding: 4px 0;
}

.property-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
}

.property-item:last-child {
  border-bottom: none;
}

.property-item-name {
  color: var(--text-primary);
  font-weight: 500;
  flex-shrink: 0;
  padding-top: 3px;
}

.property-item-value {
  color: var(--text-secondary);
  font-size: 12px;
  text-align: right;
  max-width: 50%;
}

.property-item-value.boolean {
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 10px;
}

.property-item-value.boolean.on {
  background: rgba(88, 195, 34, 0.15);
  color: var(--success);
}

.property-item-value.boolean.off {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.property-item-value.variant {
  display: flex;
  align-items: center;
  gap: 6px;
}

.property-item-value .variant-default {
  color: var(--text-primary);
  font-weight: 500;
}

.property-item-value .variant-options {
  font-size: 10px;
  color: var(--accent);
  background: rgba(0, 149, 246, 0.1);
  padding: 2px 6px;
  border-radius: 8px;
}

/* Property options display - show all variant options */
.property-item-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  max-width: 70%;
}

.variant-option-tag {
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  padding: 3px 10px;
  border-radius: 12px;
  white-space: nowrap;
}

.variant-option-tag.default {
  color: var(--text-primary);
  background: rgba(0, 149, 246, 0.12);
  font-weight: 500;
}

/* Legacy chip styles - keep for compatibility */
.properties-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.property-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-tertiary);
  border-radius: 20px;
  font-size: 13px;
}

.property-name {
  font-weight: 600;
  color: var(--text-primary);
}

.property-type {
  color: var(--text-secondary);
  font-size: 12px;
}

.property-default {
  color: var(--accent);
  font-size: 12px;
}

/* ==================== TAB BAR ==================== */
.tab-bar {
  display: flex;
  justify-content: center;
  border-top: 1px solid var(--border-color);
}

.tab-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 16px 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  border-top: 1px solid transparent;
  margin-top: -1px;
  transition: all 0.2s;
  background: none;
  border-left: none;
  border-right: none;
  border-bottom: none;
}

.tab-item:hover {
  color: var(--text-primary);
}

.tab-item.active {
  color: var(--text-primary);
  border-top-color: var(--text-primary);
}

.tab-item svg {
  width: 12px;
  height: 12px;
}

/* ==================== INSTANCES GALLERY ==================== */
.instances-gallery {
  padding-top: 4px;
}

.gallery-view {
  display: none;
}

.gallery-view.active {
  display: block;
}

.gallery-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.gallery-empty-icon {
  width: 62px;
  height: 62px;
  margin: 0 auto 16px;
  border: 2px solid var(--text-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-empty-icon svg {
  width: 28px;
  height: 28px;
  color: var(--text-primary);
}

.gallery-empty-title {
  font-size: 28px;
  font-weight: 300;
  color: var(--text-primary);
  margin-bottom: 8px;
}

/* Grid View */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.instance-card-grid {
  position: relative;
  aspect-ratio: 1;
  background: var(--bg-tertiary);
  cursor: pointer;
  overflow: hidden;
  transition: background-color 0.2s ease;
}

.instance-card-grid img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: inherit;
  transition: background-color 0.2s ease;
}

/* Adaptive background for transparent images */
.instance-card-grid img.adaptive-bg-image {
  background: inherit;
}

.instance-card-grid:hover .instance-overlay {
  opacity: 1;
}

.instance-overlay {
  position: absolute;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  opacity: 0;
  transition: opacity 0.2s;
}

.instance-overlay-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  color: white;
  font-weight: 600;
}

.instance-overlay-stat svg {
  width: 20px;
  height: 20px;
}

/* Override indicator */
.instance-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.instance-badge.override {
  background: rgba(255, 152, 0, 0.95);
  color: white;
}

.instance-badge.hidden {
  background: rgba(0, 0, 0, 0.7);
  color: white;
}

/* File grouped view */
.gallery-files {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.file-group {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}

.file-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background 0.15s ease;
}

.file-group-header:hover {
  background: var(--bg-tertiary);
}

.file-group.collapsed .file-group-header {
  border-bottom: none;
}

.file-group-collapse-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--text-secondary);
  transition: transform 0.2s ease;
}

.file-group-collapse-btn svg {
  width: 16px;
  height: 16px;
}

.file-group.collapsed .file-group-collapse-btn {
  transform: rotate(-90deg);
}

.file-group-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-group-icon {
  width: 32px;
  height: 32px;
  background: var(--bg-tertiary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-group-icon svg {
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
}

.file-group-name {
  font-weight: 600;
  font-size: 14px;
}

.file-group-count {
  font-size: 12px;
  color: var(--text-secondary);
}

.file-group-link {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.file-group-link:hover {
  text-decoration: underline;
}

.file-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 4px;
  padding: 4px;
}

.file-group.collapsed .file-group-grid {
  display: none;
}

/* Similarity grouped view */
.gallery-similarity {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.similarity-group {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px var(--shadow);
  position: relative;
}

/* Left border accent based on type */
.similarity-group::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--border-color);
  border-radius: 12px 0 0 12px;
}

.similarity-group.type-exact::before {
  background: var(--success);
}

.similarity-group.type-modified::before {
  background: var(--warning);
}

.similarity-group.type-overridden::before {
  background: var(--error);
}

.similarity-group-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 20px 16px 24px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  gap: 16px;
}

.similarity-group-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.similarity-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.similarity-title {
  font-weight: 600;
  font-size: 15px;
}

.similarity-count {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.similarity-description {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: center;
}

.similarity-description strong {
  color: var(--text-primary);
  font-weight: 600;
}

.similarity-desc-icon {
  margin-right: 2px;
}

/* Grouping criteria pills */
.similarity-criteria {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.similarity-criterion {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}

.similarity-criterion .criterion-value {
  color: var(--text-primary);
  font-weight: 600;
}

.similarity-criterion.properties {
  border-color: rgba(0, 149, 246, 0.3);
  background: rgba(0, 149, 246, 0.08);
}

.similarity-criterion.properties .criterion-value {
  color: var(--accent);
}

.similarity-criterion.text {
  border-color: rgba(136, 84, 208, 0.3);
  background: rgba(136, 84, 208, 0.08);
}

.similarity-criterion.text .criterion-value {
  color: #8854d0;
}

.similarity-criterion.visibility {
  border-color: rgba(32, 191, 107, 0.3);
  background: rgba(32, 191, 107, 0.08);
}

.similarity-criterion.visibility .criterion-value {
  color: #20bf6b;
}

.similarity-criterion.fills {
  border-color: rgba(235, 59, 90, 0.3);
  background: rgba(235, 59, 90, 0.08);
}

.similarity-criterion.fills .criterion-value {
  color: #eb3b5a;
}

.similarity-criterion.sizing {
  border-color: rgba(45, 152, 218, 0.3);
  background: rgba(45, 152, 218, 0.08);
}

.similarity-criterion.sizing .criterion-value {
  color: #2d98da;
}

.similarity-criterion.effects {
  border-color: rgba(250, 177, 160, 0.5);
  background: rgba(250, 177, 160, 0.15);
}

.similarity-criterion.effects .criterion-value {
  color: #e17055;
}

.similarity-criterion.other,
.similarity-criterion.pattern {
  border-color: rgba(255, 152, 0, 0.3);
  background: rgba(255, 152, 0, 0.08);
}

.similarity-criterion.other .criterion-value,
.similarity-criterion.pattern .criterion-value {
  color: var(--warning);
}

.similarity-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.similarity-override-count {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 5px 12px;
  background: var(--bg-secondary);
  border-radius: 16px;
  border: 1px solid var(--border-color);
  white-space: nowrap;
}

.similarity-override-count strong {
  color: var(--text-primary);
  font-weight: 600;
}

.similarity-badge {
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 14px;
  background: var(--bg-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.similarity-badge.exact {
  background: rgba(88, 195, 34, 0.15);
  color: var(--success);
}

.similarity-badge.modified {
  background: rgba(255, 152, 0, 0.15);
  color: var(--warning);
}

.similarity-badge.overridden {
  background: rgba(237, 73, 86, 0.15);
  color: var(--error);
}

.similarity-badge.minimal {
  background: rgba(88, 195, 34, 0.1);
  color: var(--success);
}

.similarity-badge.light {
  background: rgba(255, 193, 7, 0.15);
  color: #b8860b;
}

.similarity-badge.moderate {
  background: rgba(255, 152, 0, 0.15);
  color: var(--warning);
}

.similarity-badge.heavy {
  background: rgba(237, 73, 86, 0.15);
  color: var(--error);
}

.similarity-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 4px;
  padding: 4px;
}

/* ==================== INSTANCE DETAIL MODAL (Instagram-style) ==================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.visible {
  display: flex;
}

/* Navigation Arrows */
.modal-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 16px;
  z-index: 202;
  opacity: 0.8;
  transition: opacity 0.2s, transform 0.2s;
}

.modal-nav:hover {
  opacity: 1;
  transform: translateY(-50%) scale(1.1);
}

.modal-nav svg {
  width: 32px;
  height: 32px;
}

.modal-nav-prev {
  left: 16px;
}

.modal-nav-next {
  right: 16px;
}

.instance-modal {
  background: var(--bg-secondary);
  border-radius: 4px;
  width: 900px;
  max-width: calc(100vw - 160px);
  height: 85vh;
  max-height: 600px;
  display: flex;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.3);
  position: relative;
}

.modal-close {
  position: absolute;
  top: -40px;
  right: -40px;
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 8px;
  z-index: 201;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.modal-close:hover {
  opacity: 1;
}

.modal-close svg {
  width: 24px;
  height: 24px;
}

/* Left side - Image */
.modal-image-side {
  flex: 1;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  transition: background-color 0.2s ease;
}

.modal-image {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.modal-image-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px;
}

.modal-image-fallback img {
  max-width: 200px;
  max-height: 200px;
  object-fit: contain;
  opacity: 0.6;
}

.modal-image-fallback span {
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
}

.modal-image-empty {
  color: rgba(255, 255, 255, 0.3);
}

.modal-image-empty svg {
  width: 64px;
  height: 64px;
}

/* Right side - Details panel */
.modal-details-side {
  width: 340px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

/* Panel Header - Component info */
.modal-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
}

.modal-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  flex-shrink: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
}

.modal-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-avatar-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--accent), var(--gradient-end));
}

.modal-header-info {
  flex: 1;
  min-width: 0;
}

.modal-component-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-component-file {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Instance Header */
.modal-instance-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-tertiary);
}

.modal-instance-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.modal-instance-name-link {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}

.modal-instance-name-link:hover {
  text-decoration: underline;
}

.modal-instance-name-link svg {
  flex-shrink: 0;
  opacity: 0.7;
}

/* Panel Content (scrollable) */
.modal-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

/* Location */
.modal-location {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-location-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
}

.location-label {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.location-value {
  color: var(--text-primary);
  word-break: break-word;
}

/* Content Sections */
.modal-content-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
}

.modal-content-section:last-child {
  border-bottom: none;
}

.modal-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

/* Variant Info */
.modal-variant-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.variant-current {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.modal-variant-info .variant-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-word;
  max-width: none;
  overflow: visible;
  text-overflow: unset;
  white-space: normal;
}

.variant-default-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--success);
  background: rgba(88, 195, 34, 0.1);
  padding: 2px 8px;
  border-radius: 10px;
}

.variant-none {
  font-size: 12px;
  color: var(--text-secondary);
  font-style: italic;
}

.variant-diffs {
  background: rgba(255, 152, 0, 0.06);
  border-radius: 6px;
  padding: 10px;
}

.variant-diffs-label {
  font-size: 11px;
  color: var(--warning);
  font-weight: 500;
  margin-bottom: 6px;
}

.variant-diff-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  padding: 4px 0;
}

.diff-prop {
  color: var(--text-secondary);
}

.diff-values {
  display: flex;
  align-items: center;
  gap: 6px;
}

.diff-old {
  color: var(--text-secondary);
  text-decoration: line-through;
  font-size: 11px;
}

.diff-arrow {
  color: var(--text-secondary);
  font-size: 10px;
}

.diff-new {
  color: var(--warning);
  font-weight: 600;
}

/* Props Section */
.props-section {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
}

.props-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.prop-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  font-size: 11px;
  gap: 4px;
}

.prop-key {
  color: var(--text-secondary);
}

.prop-val {
  font-weight: 600;
  color: var(--text-primary);
}

/* Overrides List */
.modal-overrides-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.override-group {
  margin-bottom: 4px;
}

.override-group:last-child {
  margin-bottom: 0;
}

.override-group-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.override-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  margin-bottom: 4px;
}

.override-row:last-child {
  margin-bottom: 0;
}

.override-row.property {
  background: rgba(255, 152, 0, 0.06);
}

.override-row.text {
  background: rgba(0, 149, 246, 0.04);
}

.override-name {
  color: var(--warning);
  font-weight: 500;
  flex-shrink: 0;
  max-width: 45%;
  word-break: break-word;
}

.override-row.text .override-name {
  color: var(--accent);
}

.override-val {
  color: var(--text-primary);
  text-align: right;
  word-break: break-word;
  max-width: 50%;
}

.override-row.text .override-val {
  font-style: italic;
  color: var(--text-secondary);
}

.no-overrides {
  font-size: 12px;
  color: var(--success);
  padding: 4px 0;
}

/* Panel Footer */
.modal-panel-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-tertiary);
}

.modal-meta-info {
  font-size: 11px;
  color: var(--text-secondary);
}

.modal-instance-counter {
  font-size: 11px;
  color: var(--text-secondary);
}

/* ==================== SETTINGS MODAL ==================== */
.settings-modal {
  background: var(--bg-secondary);
  border-radius: 12px;
  max-width: 480px;
  width: 100%;
  padding: 24px;
  max-height: 90vh;
  overflow-y: auto;
}

.settings-section {
  margin-bottom: 24px;
}

.settings-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
  text-align: center;
}

.settings-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 24px;
}

.settings-form-group {
  margin-bottom: 16px;
}

.settings-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.settings-input {
  width: 100%;
  padding: 12px;
  font-size: 14px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-tertiary);
}

.settings-input:focus {
  outline: none;
  border-color: var(--accent);
}

.settings-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.settings-hint a {
  color: var(--accent);
}

/* Teams List */
.teams-list {
  margin-bottom: 12px;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-tertiary);
}

.teams-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
}

.team-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.2s;
}

.team-item:last-child {
  border-bottom: none;
}

.team-item:hover {
  background: var(--bg-secondary);
}

.team-item.verified .team-name {
  color: var(--text-primary);
}

.team-item.error .team-name {
  color: var(--error);
}

.team-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.team-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.team-icon-placeholder {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--gradient-start) 100%);
  flex-shrink: 0;
}

.team-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.team-id {
  font-size: 11px;
  color: var(--text-secondary);
  font-family: 'Monaco', 'Consolas', monospace;
}

.team-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.team-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.team-verified-icon {
  width: 18px;
  height: 18px;
  color: var(--success);
}

.team-error-icon {
  width: 18px;
  height: 18px;
  color: var(--error);
}

.team-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.team-remove-btn {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.team-remove-btn:hover {
  background: rgba(237, 73, 86, 0.1);
  color: var(--error);
}

.team-remove-btn svg {
  width: 16px;
  height: 16px;
}

/* Add Team Row */
.add-team-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.add-team-input {
  flex: 1;
}

.add-team-btn {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  transition: background 0.2s;
}

.add-team-btn:hover {
  background: var(--accent-hover);
}

.add-team-btn svg {
  width: 20px;
  height: 20px;
}

.settings-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.settings-actions button {
  flex: 1;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
}

.settings-cancel {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.settings-save {
  background: var(--accent);
  border: none;
  color: white;
}

.settings-save:hover {
  background: var(--accent-hover);
}

/* Settings Modal Header */
.settings-modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.settings-modal .modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.settings-modal .modal-close {
  position: static;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.settings-modal .modal-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.settings-modal .modal-close svg {
  width: 20px;
  height: 20px;
}

/* Settings Modal Body */
.settings-modal .modal-body {
  padding: 0;
}

/* Settings Modal Footer */
.settings-modal .modal-footer {
  display: flex;
  gap: 12px;
  padding-top: 20px;
  margin-top: 8px;
  border-top: 1px solid var(--border-color);
}

/* Settings Modal Action Buttons */
.modal-action-btn {
  flex: 1;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.modal-action-btn.secondary {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.modal-action-btn.secondary:hover {
  background: var(--border-light);
}

.modal-action-btn.primary {
  background: var(--accent);
  color: white;
}

.modal-action-btn.primary:hover {
  background: var(--accent-hover);
}

/* ==================== SCOPE SELECTION MODAL ==================== */
.scope-modal {
  background: var(--bg-secondary);
  border-radius: 12px;
  max-width: 500px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.scope-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  min-height: 48px;
}

.scope-modal-close {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.scope-modal-close svg {
  width: 20px;
  height: 20px;
}

.scope-modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.scope-modal-action {
  background: none;
  border: none;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}

.scope-modal-action:hover {
  color: var(--accent-hover);
}

.scope-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.scope-quick-actions {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.scope-quick-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-tertiary);
  border: none;
  border-radius: 20px;
  cursor: pointer;
  color: var(--text-primary);
  transition: all 0.2s;
}

.scope-quick-btn:hover {
  background: var(--border-color);
}

.scope-quick-btn svg {
  width: 14px;
  height: 14px;
}

.scope-teams-list {
  display: flex;
  flex-direction: column;
}

.scope-team {
  border-bottom: 1px solid var(--border-color);
}

.scope-team:last-child {
  border-bottom: none;
}

.scope-team-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.2s;
}

.scope-team-header:hover {
  background: var(--bg-tertiary);
}

.scope-team-checkbox {
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  position: relative;
}

.scope-team-checkbox:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.scope-team-checkbox:checked::after {
  content: '';
  position: absolute;
  width: 6px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  top: 3px;
  left: 6px;
}

.scope-team-icon {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.scope-team-icon-placeholder {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--gradient-start) 100%);
  flex-shrink: 0;
}

.scope-team-info {
  flex: 1;
  min-width: 0;
}

.scope-team-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scope-team-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.scope-team-expand {
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: transform 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scope-team-expand.expanded {
  transform: rotate(180deg);
}

.scope-team-expand svg {
  width: 20px;
  height: 20px;
}

.scope-files-list {
  display: none;
  background: var(--bg-tertiary);
  max-height: 300px;
  overflow-y: auto;
}

.scope-files-list.expanded {
  display: block;
}

/* Project level styles */
.scope-project {
  border-bottom: 1px solid var(--border-light);
}

.scope-project:last-child {
  border-bottom: none;
}

.scope-project-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 10px 24px;
  cursor: pointer;
  transition: background 0.2s;
}

.scope-project-header:hover {
  background: var(--border-light);
}

.scope-project-checkbox {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  border-radius: 4px;
  border: 2px solid var(--border-color);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: all 0.2s;
  flex-shrink: 0;
  position: relative;
}

.scope-project-checkbox:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.scope-project-checkbox:checked::after {
  content: '';
  position: absolute;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  top: 2px;
  left: 5px;
}

.scope-project-checkbox:indeterminate {
  background: var(--accent);
  border-color: var(--accent);
}

.scope-project-checkbox:indeterminate::after {
  content: '';
  position: absolute;
  width: 8px;
  height: 2px;
  background: white;
  top: 6px;
  left: 3px;
  border: none;
  transform: none;
}

.scope-project-icon {
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.scope-project-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.scope-project-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scope-project-count {
  font-size: 11px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.scope-project-expand {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: transform 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.scope-project-expand.expanded {
  transform: rotate(180deg);
}

.scope-project-expand svg {
  width: 16px;
  height: 16px;
}

.scope-project-files {
  display: none;
  padding-left: 20px;
}

.scope-project-files.expanded {
  display: block;
}

/* File level styles */
.scope-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 8px 44px;
  transition: background 0.2s;
}

.scope-file:hover {
  background: var(--border-light);
}

.scope-file-checkbox {
  width: 16px;
  height: 16px;
  min-width: 16px;
  min-height: 16px;
  border-radius: 4px;
  border: 2px solid var(--border-color);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: all 0.2s;
  flex-shrink: 0;
  position: relative;
}

.scope-file-checkbox:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.scope-file-checkbox:checked::after {
  content: '';
  position: absolute;
  width: 4px;
  height: 7px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  top: 1px;
  left: 4px;
}

.scope-file-icon {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.scope-file-name {
  flex: 1;
  font-size: 12px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Team checkbox indeterminate state */
.scope-team-checkbox:indeterminate {
  background: var(--accent);
  border-color: var(--accent);
}

.scope-team-checkbox:indeterminate::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 2px;
  background: white;
  top: 8px;
  left: 4px;
  border: none;
  transform: none;
}

.scope-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  color: var(--text-secondary);
  font-size: 14px;
}

.loading-spinner.small {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

.scope-empty {
  text-align: center;
  padding: 40px 20px;
}

.scope-empty-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  color: var(--text-secondary);
}

.scope-empty-icon svg {
  width: 100%;
  height: 100%;
}

.scope-empty p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 16px;
}

.scope-empty-btn {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  color: white;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.scope-empty-btn:hover {
  background: var(--accent-hover);
}

.scope-modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
}

.scope-footer-btn {
  width: 100%;
  padding: 12px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.scope-footer-btn.primary {
  background: var(--accent);
  border: none;
  color: white;
}

.scope-footer-btn.primary:hover {
  background: var(--accent-hover);
}

.scope-footer-btn.secondary {
  background: transparent;
  border: none;
  color: var(--text-secondary);
}

.scope-footer-btn.secondary:hover {
  color: var(--text-primary);
}

.scope-files-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  color: var(--text-secondary);
  font-size: 13px;
  background: var(--bg-tertiary);
}

/* ==================== TOAST NOTIFICATION ==================== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text-primary);
  color: var(--bg-secondary);
  padding: 14px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 300;
  transition: transform 0.3s ease;
  box-shadow: 0 4px 12px var(--shadow);
}

.toast.visible {
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: var(--error);
  color: white;
}

.toast.success {
  background: var(--success);
  color: white;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
  .profile-header {
    flex-direction: column;
    gap: 24px;
    text-align: center;
  }
  
  .profile-avatar {
    margin: 0 auto;
  }
  
  .avatar-wrapper {
    width: 110px;
    height: 110px;
  }
  
  .profile-title-row {
    flex-direction: column;
    gap: 12px;
    justify-content: center;
  }
  
  .profile-stats {
    justify-content: center;
  }
  
  .profile-actions {
    justify-content: center;
  }
  
  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
  }
  
  /* Mobile Modal */
  .modal-overlay {
    padding: 0;
  }
  
  .instance-modal {
    flex-direction: column;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    max-width: 100%;
  }
  
  .modal-image-side {
    min-width: unset;
    max-width: 100%;
    flex: 0 0 auto;
    height: 40vh;
  }
  
  .modal-details-side {
    width: 100%;
    flex: 1;
    border-left: none;
    border-top: 1px solid var(--border-color);
  }
  
  .modal-close {
    top: 8px;
    right: 8px;
  }
  
  .tab-item {
    padding: 12px 12px;
    font-size: 10px;
  }
}

/* ==================== UTILITY CLASSES ==================== */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.text-secondary {
  color: var(--text-secondary);
}

/* ==================== ADDITIONAL FILES ==================== */
.additional-files-list {
  margin-bottom: 12px;
  max-height: 150px;
  overflow-y: auto;
}

.additional-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 13px;
}

.additional-file-item .file-name {
  color: var(--text-primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.additional-file-item .file-remove {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  margin-left: 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.additional-file-item .file-remove:hover {
  background: rgba(255, 0, 0, 0.1);
  color: #e74c3c;
}

.add-file-input-row {
  display: flex;
  align-items: center;
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ==================== VARIANT DETAIL MODAL (Stories-style) ==================== */
.variant-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.variant-modal-overlay.visible {
  opacity: 1;
}

.variant-modal {
  background: var(--bg-secondary);
  border-radius: 12px;
  max-width: 420px;
  width: 90%;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  transform: scale(0.95);
  transition: transform 0.2s ease;
}

.variant-modal-overlay.visible .variant-modal {
  transform: scale(1);
}

.variant-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.2s;
}

.variant-modal-close:hover {
  background: rgba(0, 0, 0, 0.7);
}

.variant-modal-close svg {
  width: 20px;
  height: 20px;
}

.variant-modal-image {
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  max-height: 400px;
  padding: 24px;
  position: relative;
  transition: background-color 0.2s ease;
}

.variant-modal-image img {
  max-width: 100%;
  max-height: 350px;
  object-fit: contain;
}

.variant-modal-no-image {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: rgba(255, 255, 255, 0.4);
}

.variant-modal-no-image span {
  font-size: 13px;
}

.variant-modal-info {
  padding: 16px;
  border-top: 1px solid var(--border-color);
}

.variant-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.variant-modal-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--border-color);
}

.variant-modal-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.variant-modal-meta {
  flex: 1;
  min-width: 0;
}

.variant-modal-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 2px;
}

.variant-modal-component {
  font-size: 12px;
  color: var(--text-secondary);
}

.variant-modal-props {
  background: var(--bg-tertiary);
  border-radius: 8px;
  padding: 4px 0;
  margin-bottom: 16px;
}

.variant-prop-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-light);
}

.variant-prop-row:last-child {
  border-bottom: none;
}

.variant-prop-key {
  color: var(--text-secondary);
}

.variant-prop-value {
  font-weight: 600;
  color: var(--text-primary);
}

.variant-modal-figma-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background: var(--accent);
  color: white;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  transition: background 0.2s;
}

.variant-modal-figma-link:hover {
  background: var(--accent-hover);
}

/* Responsive variant modal */
@media (max-width: 500px) {
  .variant-modal {
    max-width: 100%;
    width: 100%;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
  }
  
  .variant-modal-image {
    flex: 1;
    max-height: none;
  }
}
