/* ────────────────────────────────────────────────────────────────
   Formula slots (the three dashes area: e.g., S V V)
   Usage: <div class="formula-slots"><span class="formula-slot"></span>...</div>
   Add .filled and data-letter="S|V" when user fills a slot.
   ──────────────────────────────────────────────────────────────── */
   .formula-slots {
    display: inline-flex;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(6px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25) inset, 0 6px 24px rgba(0, 0, 0, 0.15);
    align-items: center;
  }
  .formula-slot {
    position: relative;
    width: 44px;
    height: 22px;
    border-bottom: 3px dashed rgba(255, 255, 255, 0.45);
    transition: all 160ms ease;
  }
  .formula-slot:hover {
    transform: translateY(-1px);
    border-bottom-color: rgba(255, 255, 255, 0.7);
  }
  .formula-slot.filled {
    border-bottom-color: transparent;
  }
  .formula-slot.filled::after {
    content: attr(data-letter);
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-weight: 800;
    letter-spacing: 1px;
    color: #0f172a;
    background: linear-gradient(180deg, #a7f3d0, #6ee7b7);
    border-radius: 10px;
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.35);
    animation: formulaPop 200ms ease-out both;
  }
  @keyframes formulaPop {
    0% { transform: translateY(4px) scale(0.9); opacity: 0; }
    100% { transform: translateY(-4px) scale(1.02); opacity: 1; }
  }
  
  /* ────────────────────────────────────────────────────────────────
     Word annotation tooltip (appears above a clicked word)
     Usage: absolutely-position near the word container
     Buttons: .ann-btn, with modifiers .ann-btn--S / --V / --HV
     ──────────────────────────────────────────────────────────────── */
  .annotation-tooltip {
    position: absolute;
    z-index: 50;
    top: -52px; /* adjust based on word height */
    left: 50%;
    transform: translateX(-50%);
    display: inline-flex;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 10px;
    background: rgba(2, 6, 23, 0.82);
    color: #e2e8f0;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(148, 163, 184, 0.25);
    box-shadow: 0 10px 30px rgba(0,0,0,0.35);
    animation: tooltipRise 140ms ease-out both;
  }
  .annotation-tooltip::after {
    content: "";
    position: absolute;
    bottom: -7px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 7px 7px 0 7px;
    border-style: solid;
    border-color: rgba(2, 6, 23, 0.82) transparent transparent transparent;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.25));
  }
  @keyframes tooltipRise {
    from { transform: translate(-50%, 6px); opacity: 0; }
    to   { transform: translate(-50%, 0); opacity: 1; }
  }
  .ann-btn {
    appearance: none;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.65);
    color: #e2e8f0;
    font-size: 12px;
    font-weight: 700;
    padding: 6px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
    text-transform: uppercase;
    letter-spacing: .4px;
  }
  .ann-btn:hover { transform: translateY(-1px); }
  .ann-btn--S { border-color: rgba(59, 130, 246, 0.6); background: rgba(59, 130, 246, 0.18); }
  .ann-btn--V { border-color: rgba(34, 197, 94, 0.6); background: rgba(34, 197, 94, 0.18); }
  .ann-btn--HV { border-color: rgba(168, 85, 247, 0.6); background: rgba(168, 85, 247, 0.18); }
  
  /* ────────────────────────────────────────────────────────────────
     Word tag chips (labels above words after selection)
     Apply .word-has-tag on the word container and inject child .word-tag
     ──────────────────────────────────────────────────────────────── */
  .word-has-tag {
    position: relative; /* ensure tag positioning */
  }
  .word-tag {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translate(-50%, -6px);
    font-size: 11px;
    line-height: 1;
    font-weight: 800;
    padding: 4px 6px;
    border-radius: 6px;
    color: #0f172a;
    background: #e2e8f0;
    border: 1px solid rgba(15, 23, 42, 0.15);
    white-space: nowrap;
    box-shadow: 0 8px 18px rgba(0,0,0,0.25);
    animation: chipPop 160ms ease-out both;
  }
  .word-tag::before {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translate(-50%, -1px);
    border-width: 6px 6px 0 6px;
    border-style: solid;
    border-color: #e2e8f0 transparent transparent transparent;
  }
  .word-tag--S { background: #bfdbfe; border-color: rgba(37, 99, 235, 0.35); }
  .word-tag--V { background: #bbf7d0; border-color: rgba(22, 163, 74, 0.35); }
  .word-tag--HV { background: #e9d5ff; border-color: rgba(147, 51, 234, 0.35); }
  @keyframes chipPop {
    from { transform: translate(-50%, 0) scale(.9); opacity: 0; }
    to   { transform: translate(-50%, -6px) scale(1); opacity: 1; }
  }
  
  /* ────────────────────────────────────────────────────────────────
     Verb grouping (helping verb + main verb) – wrapper approach
     Wrap both words with <span class="verb-group"><span class="word">...</span> <span class="word">...</span><span class="verb-group-label">Verb</span></span>
     ──────────────────────────────────────────────────────────────── */
  .verb-group {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border-radius: 12px;
    background: rgba(16, 185, 129, 0.15);
    border: 2px solid rgba(16, 185, 129, 0.55);
    box-shadow: 0 8px 28px rgba(16,185,129,0.25) inset, 0 6px 24px rgba(0,0,0,0.25);
    animation: verbMerge 220ms ease-out both;
  }
  .verb-group .word {
    padding: 0 2px;
    border-radius: 8px;
    background: rgba(16, 185, 129, 0.08);
  }
  .verb-group-label {
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #bbf7d0;
    border: 1px solid rgba(16,185,129,0.6);
    color: #064e3b;
    font-size: 10px;
    font-weight: 900;
    padding: 2px 6px;
    border-radius: 999px;
    letter-spacing: .4px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
  }
  @keyframes verbMerge {
    0% { transform: scale(0.96); box-shadow: 0 0 0 rgba(16,185,129,0); }
    100% { transform: scale(1); box-shadow: 0 8px 28px rgba(16,185,129,0.25) inset, 0 6px 24px rgba(0,0,0,0.25); }
  }
  
  /* ────────────────────────────────────────────────────────────────
     Verb grouping – fallback (no wrapper): mark contiguous pair parent with .verb-pair
     Structure: <span class="verb-pair"><span class="word">was</span><span class="word">covered</span></span>
     ──────────────────────────────────────────────────────────────── */
  .verb-pair {
    display: inline-flex;
    align-items: center;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid rgba(16,185,129,0.55);
    background: rgba(16,185,129,0.12);
    animation: verbMerge 220ms ease-out both;
  }
  .verb-pair .word {
    padding: 0 4px;
    background: rgba(16,185,129,0.08);
  }
  .verb-pair .word + .word {
    border-left: 1px dashed rgba(16,185,129,0.45);
  }
  
  /* ────────────────────────────────────────────────────────────────
     Animated connector (if you inject a bridging span between words)
     Usage: <span class="verb-bridge"></span> placed between the two words
     ──────────────────────────────────────────────────────────────── */
  .verb-bridge {
    display: inline-block;
    height: 10px;
    width: 0;
    border-top: 2px dashed rgba(16,185,129,0.6);
    transform: translateY(-2px);
    animation: bridgeGrow 220ms ease-out forwards;
  }
  @keyframes bridgeGrow {
    from { width: 0; opacity: .2; }
    to   { width: 10px; opacity: 1; }
  }
  
  /* ────────────────────────────────────────────────────────────────
     Focus ring when a word is "armed" for annotation (optional)
     Add .word-armed to a word to hint it's clickable
     ──────────────────────────────────────────────────────────────── */
  .word-armed {
    outline: 2px dashed rgba(148, 163, 184, 0.55);
    outline-offset: 3px;
    border-radius: 8px;
    background: rgba(255,255,255,0.06);
    animation: armedPulse 900ms ease-in-out infinite;
  }
  @keyframes armedPulse {
    0% { box-shadow: 0 0 0 0 rgba(148,163,184,0.25); }
    70% { box-shadow: 0 0 0 6px rgba(148,163,184,0); }
    100% { box-shadow: 0 0 0 0 rgba(148,163,184,0); }
  }
  
  /* ────────────────────────────────────────────────────────────────
     Subtle success glow when a tag is placed on a word
     ──────────────────────────────────────────────────────────────── */
  .word-tag--V,
  .verb-group,
  .verb-pair {
    box-shadow: 0 0 0 0 rgba(16,185,129,0.35);
    animation: successPulse 900ms ease-out 1;
  }
  @keyframes successPulse {
    0% { box-shadow: 0 0 0 0 rgba(16,185,129,0.35); }
    100% { box-shadow: 0 0 0 12px rgba(16,185,129,0); }
  }
  
  /* ────────────────────────────────────────────────────────────────
     Compact helper: place S/V chip above a grouped verb (centered)
     Usage: <span class="group-chip">Verb</span> positioned inside .verb-group or .verb-pair
     ──────────────────────────────────────────────────────────────── */
  .group-chip {
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    font-weight: 900;
    color: #064e3b;
    background: #bbf7d0;
    border: 1px solid rgba(16,185,129,0.6);
    border-radius: 999px;
    padding: 2px 6px;
    letter-spacing: .4px;
    white-space: nowrap;
  }
  
  /* ────────────────────────────────────────────────────────────────
     Micro utility: a faint underline to show "this token is labeled"
     Add to any labeled word if you want an extra cue
     ──────────────────────────────────────────────────────────────── */
  .word-labeled {
    background-image: linear-gradient(currentColor, currentColor);
    background-repeat: no-repeat;
    background-size: 100% 2px;
    background-position: 0 100%;
    text-decoration: none;
    text-underline-offset: 4px;
    color: inherit;
    opacity: .96;
  }
  
  .word, .word-anchored { position: relative; display: inline-block; vertical-align: baseline; }
  .verb-group { overflow: visible; }
  .annotation-tooltip { position: absolute; z-index: 2000; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); }
  .annotation-tooltip::after { top: 100%; left: 50%; transform: translateX(-50%); }
  
  .compose-field {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
  }
  .compose-hint-line {
    position: absolute;
    right: 12px;             /* mirrors input right padding */
    bottom: 14px;            /* near the text baseline */
    height: 2px;
    background: rgba(148, 163, 184, 0.45);
    border-radius: 2px;
    pointer-events: none;
  }
  .compose-measure {
    position: absolute;
    visibility: hidden;
    pointer-events: none;
    white-space: pre;        /* keep spaces */
    font-size: 14px;         /* must match input font-size */
    padding: 10px 12px;      /* match input padding for accurate width */
  }