.popup-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 99998;
  background: transparent;
}

.text-selection-popup {
  position: fixed;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: linear-gradient(180deg, #2d3139 0%, #252830 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3), 0 0 1px rgba(0, 0, 0, 0.2);
  z-index: 99999;
  transform: translateX(-50%);
  animation: popupFadeIn 0.15s ease-out;

  &.show-below {
    animation: popupFadeInBelow 0.15s ease-out;
  }
}

@keyframes popupFadeIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes popupFadeInBelow {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  transition: all 0.15s ease;

  &:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
  }

  &.active {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
  }

  svg {
    flex-shrink: 0;
  }

  .chevron {
    margin-left: -2px;
    transition: transform 0.2s ease;

    &.open {
      transform: rotate(180deg);
    }
  }
}

.delete-btn {
  &:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
  }
}

.divider {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.1);
  margin: 0 2px;
}

.annotation-container {
  position: relative;
}

.annotation-options {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px;
  background: linear-gradient(180deg, #2d3139 0%, #252830 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  z-index: 100000;
  display: flex;
  flex-direction: column;
  gap: 8px;

  &.above {
    bottom: calc(100% + 8px);
    animation: slideUp 0.15s ease-out;
  }

  &.below {
    top: calc(100% + 8px);
    animation: slideDown 0.15s ease-out;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.style-buttons {
  display: flex;
  gap: 4px;
}

.style-btn {
  width: 32px;
  height: 28px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;

  .style-text {
    display: block;
  }

  &.highlight-style .style-text {
    background: linear-gradient(180deg, rgba(255, 255, 0, 0.4) 60%, transparent 60%);
  }

  &.underline-style .style-text {
    text-decoration: underline;
    text-decoration-thickness: 2px;
  }

  &.squiggly-style .style-text {
    text-decoration: underline wavy;
  }

  &.strikethrough-style .style-text {
    text-decoration: line-through;
  }

  &:hover {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
  }

  &.selected {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.15);
    color: #fff;
  }
}

.color-buttons {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.color-btn {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  background: var(--color);
  cursor: pointer;
  transition: all 0.15s ease;

  &:hover {
    transform: scale(1.1);
  }

  &.selected {
    border-color: #fff;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
  }
}

