.marginalia {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono, monospace);
  font-size: 0.75rem;
  font-style: italic;
  line-height: 1.4;
  pointer-events: none;
  transform: rotate(var(--rotation, -5deg));
}

/* POSITIONS */

.left {
  right: calc(100% + 1rem);
  top: 0;
  text-align: right;
}

.right {
  left: calc(100% + 1rem);
  top: 0;
  text-align: left;
}

.top-left {
  bottom: calc(100% + 0.5rem);
  left: 0;
}

.top-right {
  bottom: calc(100% + 0.5rem);
  right: 0;
  text-align: right;
}

.bottom-left {
  top: calc(100% + 0.5rem);
  left: 0;
}

.bottom-right {
  top: calc(100% + 0.5rem);
  right: 0;
  text-align: right;
}

/* STYLES */

/* Pencil - light, hand-drawn look */
.pencil {
  color: #666;
  background: rgba(255, 255, 200, 0.3);
  padding: 0.25rem 0.5rem;
  border-radius: 2px;
  border: 1px dashed #999;
}

.pencil::before {
  content: '';
  position: absolute;
  inset: -2px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 4px;
  pointer-events: none;
}

/* Ink - bold, permanent look */
.ink {
  color: #000;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.75rem;
  border-left: 3px solid #000;
}

.ink .arrow {
  color: #cc0000;
  font-weight: 700;
}

/* Highlighter - bright marker effect */
.highlighter {
  color: #000;
  background: linear-gradient(180deg, rgba(255, 255, 0, 0.4) 0%, rgba(255, 255, 0, 0.2) 100%);
  padding: 0.125rem 0.5rem;
  border-radius: 2px;
  font-style: normal;
}

.highlighter::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(255, 200, 0, 0.5);
}

/* Sticker - post-it note style */
.sticker {
  background: linear-gradient(135deg, #ffff66 0%, #ffff00 100%);
  color: #000;
  padding: 0.5rem 0.75rem;
  box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
  font-style: normal;
  font-weight: 600;
  transform: rotate(var(--rotation, -5deg)) translateY(-5px);
}

.sticker::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 10px;
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.1) 0%, transparent 100%);
}

/* ELEMENTS */

.label {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  opacity: 0.7;
  margin-right: 0.25rem;
}

.content {
  flex: 1;
}

.arrow {
  color: #cc0000;
  font-weight: 700;
  animation: arrow-bounce 1s ease-in-out infinite;
}

@keyframes arrow-bounce {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(3px); }
}

/* VARIANTS */

/* Circled */
.marginalia.circled .content {
  border: 2px solid currentColor;
  border-radius: 50%;
  padding: 0.25rem 0.75rem;
}

/* Underlined */
.marginalia.underlined .content {
  border-bottom: 2px solid currentColor;
  padding-bottom: 0.125rem;
}

/* Boxed */
.marginalia.boxed .content {
  border: 2px solid currentColor;
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
}

/* Starred */
.marginalia.starred .label::before {
  content: '★ ';
  color: #ffcc00;
}

/* Numbered */
.marginalia.numbered .label::before {
  content: '1. ';
}

/* Checkmarked */
.marginalia.checked::after {
  content: '✓';
  color: #00aa00;
  font-weight: 700;
  margin-left: 0.25rem;
}

/* Crossed */
.marginalia.crossed::after {
  content: '✗';
  color: #aa0000;
  font-weight: 700;
  margin-left: 0.25rem;
}

/* Question marked */
.marginalia.questioned .label::before {
  content: '? ';
  color: #cc0000;
  font-weight: 700;
}

/* Exclamation marked */
.marginalia.exclaimed .label::before {
  content: '! ';
  color: #cc0000;
  font-weight: 700;
}

/* COLOR VARIANTS */

/* Red ink */
.marginalia.red-ink {
  color: #cc0000;
  border-color: #cc0000;
}

/* Blue ink */
.marginalia.blue-ink {
  color: #0066cc;
  border-color: #0066cc;
}

/* Green ink */
.marginalia.green-ink {
  color: #00aa00;
  border-color: #00aa00;
}

/* Purple ink */
.marginalia.purple-ink {
  color: #6600cc;
  border-color: #6600cc;
}

/* SIZE VARIANTS */

.small {
  font-size: 0.625rem;
  padding: 0.125rem 0.25rem;
}

.large {
  font-size: 0.875rem;
  padding: 0.375rem 1rem;
}

/* ANIMATED */

.marginalia.animated {
  animation: marginalia-appear 0.3s ease forwards;
}

@keyframes marginalia-appear {
  from {
    opacity: 0;
    transform: rotate(var(--rotation, -5deg)) scale(0.8);
  }
  to {
    opacity: 1;
    transform: rotate(var(--rotation, -5deg)) scale(1);
  }
}

.marginalia.pulsing {
  animation: marginalia-pulse 2s ease-in-out infinite;
}

@keyframes marginalia-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.marginalia.shaking {
  animation: marginalia-shake 0.5s ease-in-out infinite;
}

@keyframes marginalia-shake {
  0%, 100% { transform: rotate(var(--rotation, -5deg)); }
  25% { transform: rotate(calc(var(--rotation, -5deg) - 2deg)); }
  75% { transform: rotate(calc(var(--rotation, -5deg) + 2deg)); }
}
