.margin-text {
  position: relative;
  max-width: 65ch;
  margin: 0 auto 2em auto;
  line-height: 1.7;
  font-size: 1.1em;
  padding: 0 12em 0 2em; /* Wide right margin for notes */
}

.annotated {
  position: relative;
  border-bottom: 1px dotted var(--accent-color, #b8860b);
  cursor: help;
  transition: all 0.2s ease;
}

.annotated:hover {
  background-color: rgba(var(--accent-color-rgb, 184, 134, 11), 0.1);
}

.margin-note {
  position: absolute;
  right: -11em;
  width: 10em;
  font-size: 0.85em;
  line-height: 1.4;
  color: var(--text-light, #666);
  opacity: 0;
  transform: translateX(20px);
  transition: all 0.3s ease;
  pointer-events: none;
  background: var(--bg-color, #fdf8f0);
  border-left: 2px solid var(--accent-color, #b8860b);
  padding: 0.5em 0 0.5em 0.8em;
  z-index: 10;
}

.annotated:hover .margin-note {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.margin-note::before {
  content: "┌";
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent-color, #b8860b);
  font-size: 1.2em;
}

/* Mobile responsive - inline expansion */
@media (max-width: 768px) {
  .margin-text {
    padding: 0 1em;
  }
  
  .margin-note {
    position: static;
    right: auto;
    width: auto;
    transform: none;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity 0.3s ease, max-height 0.3s ease;
    margin-top: 0.5em;
    border-left: 3px solid var(--accent-color, #b8860b);
    background: rgba(var(--accent-color-rgb, 184, 134, 11), 0.05);
  }
  
  .margin-note::before {
    content: "→ ";
    position: static;
    transform: none;
  }
  
  .annotated:hover .margin-note {
    opacity: 1;
    max-height: 200px;
    transform: none;
  }
}

/* Demo text styling */
.demo-container {
  margin: 3em 0;
  padding: 2em;
  border: 1px solid rgba(var(--accent-color-rgb, 184, 134, 11), 0.2);
  background: rgba(var(--accent-color-rgb, 184, 134, 11), 0.02);
}

.demo-title {
  font-weight: bold;
  margin-bottom: 1em;
  color: var(--accent-color, #b8860b);
}
