.parascope-preview {
  flex: 1;
  overflow: auto;
  overflow-x: hidden;
  padding: 24px;
  background: var(--bg-body);
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.1) 1px, transparent 1px);
  background-size: 20px 20px;
  /* Ensure preview fits within editor section */
  max-width: 100%;
  box-sizing: border-box;
  /* Make sure the preview section stretches to fill available space */
  width: 100%;
}

/* Card container for flexible layout (2 cards per row) */
.parascope-preview__container {
  display: grid;
  grid-template-columns: repeat(auto-fit, 270px);
  gap: 24px;
  justify-content: start;
  align-items: flex-start;
  max-width: 100%;
  width: 100%;
  justify-items: start;
}

/* Web project card styles */
.parascope-card {
  background: var(--bg-card);
  border: 2px solid #333333;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.04);
  box-sizing: border-box;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
  width: 270px;
  min-width: 270px;
  max-width: 270px;
}

.parascope-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.06);
}

.parascope-card__title {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0 0 14px 0;
}

.parascope-card__section {
  margin-top: 20px;
  /* Smaller font size for section content */
  font-size: 0.78em;
}

.parascope-card__section:first-of-type {
  margin-top: 0;
}

.parascope-card__section-title {
  margin: 0 0 10px 0;
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.parascope-card__list {
  margin: 0;
  padding-left: 18px;
}

/* Grid for tiles inside card: 4 tiles per row */
.parascope-card__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr); /* 4 tiles per row */
  gap: 8px;
  max-width: 100%;
  width: 100%;
}

/* Pills grid: use flex layout for pills to auto-wrap and fit content */
.parascope-card__grid:has(.parascope-pill) {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.parascope-tile {
  /* Make tile perfectly square using aspect-ratio */
  width: 100%;
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fafbfc;
  text-decoration: none;
  color: inherit;
  gap: 4px; /* Less gap for compact look */
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition:
    background 0.15s ease,
    box-shadow 0.15s ease;
  /* Ensure tile maintains fixed size regardless of content */
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.parascope-tile:hover {
  background: #f0f2f5;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.parascope-tile__icon {
  /* Smaller icon size for compact tile */
  width: 24px;
  height: 24px;
  border-radius: 6px;
  object-fit: cover;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

.parascope-tile__label {
  font-size: 0.55rem; /* Smaller text */
  text-align: center;
  line-height: 1.1;
  word-break: break-word;
  max-width: 22ch; /* Limit to 22 characters per line */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal; /* Allow text to wrap to 2 lines */
  /* Ensure text doesn't expand the tile */
  width: 100%;
  box-sizing: border-box;
  padding: 0 4px; /* Add small padding for better text spacing */
  /* Limit to 2 lines with ellipsis */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

.parascope-pill {
  display: inline-flex; /* Use flex for vertical centering */
  align-items: center;
  padding: 4px 9px 4px 5px; /* Reduced padding for smaller height */
  font-size: 0.7rem;
  border: 1px solid #0070f3;
  border-radius: 999px;
  color: #0070f3;
  text-decoration: none;
  transition: background 0.15s ease;
  margin: 0;
  min-width: 5ch;
  max-width: 30ch;
  width: auto;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 0 1 auto;
}

/* Favicon circle for pills - smaller size */
.parascope-pill__favicon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  min-width: 16px;
  min-height: 16px;
  max-width: 16px;
  max-height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #e0e3e7;
  margin-right: 6px; /* Reduced gap between icon and text */
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.parascope-pill__favicon .parascope-tile__icon {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  object-fit: cover;
}

.parascope-pill__label {
  font-size: 0.7rem;
  text-align: left;
  line-height: 1.1;
  max-width: 18ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0;
  display: inline;
}

.parascope-pill:hover {
  background: rgba(0, 112, 243, 0.08);
}

.parascope-pill--split {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 11px;
  font-size: 0.7rem;
  border: 1px solid #0070f3;
  border-radius: 999px;
  background: transparent;
  position: relative;
  cursor: pointer;
}

.parascope-pill--split .parascope-pill__label {
  color: #0070f3;
  font-weight: 500;
  padding-right: 9px;
  position: relative;
}

.parascope-pill--split .parascope-pill__label::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 1px;
  height: 12px;
  background: #0070f3;
  opacity: 0.5;
}

.parascope-pill--split .parascope-pill__value {
  color: #0070f3;
  padding-left: 9px;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  position: relative;
}

.parascope-pill--split .parascope-pill__value::after {
  content: 'Copied!';
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background: #e6f0ff;
  color: #4d94ff;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 500;
}

.parascope-pill--split.copied .parascope-pill__value::after {
  opacity: 1;
}

.parascope-pill--split:hover {
  background: rgba(0, 112, 243, 0.08);
}

.parascope-card__list-item {
  margin-bottom: 6px;
}

.parascope-preview__header {
  text-align: center;
  margin-bottom: 20px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

@media (max-width: 768px) {
  .parascope-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 0;
    width: auto;
  }
  .parascope-preview__container {
    display: flex;
    width: 100%;
    transform: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0;
  }
  .parascope-card {
    width: 340px;
    min-width: 0;
    max-width: 95vw;
    margin: 0 0 20px 0;
  }
  .parascope-card__grid {
    /* Always 4 tiles per row on mobile, grid layout */
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    max-width: 100%;
    width: 100%;
  }
  .parascope-tile {
    /* Each tile takes 1/4 of the row, always square */
    width: 100%;
    aspect-ratio: 1 / 1;
  }
  .parascope-tile__icon {
    width: 30px;
    height: 30px;
  }
  .parascope-tile__label {
    font-size: 0.7rem;
    max-width: 22ch; /* Limit to 22 characters per line */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal; /* Allow text to wrap to 2 lines */
    width: 100%;
    box-sizing: border-box;
    padding: 0 4px;
    /* Limit to 2 lines with ellipsis */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
}