dsh-reading-inbox 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/web/app.js CHANGED
@@ -9,8 +9,12 @@ const state = {
9
9
  selected: null,
10
10
  stats: null,
11
11
  listToken: 0,
12
+ selection: null,
13
+ selectionColor: 'yellow',
12
14
  }
13
15
 
16
+ const ANNOTATION_COLORS = ['yellow', 'green', 'blue', 'red']
17
+
14
18
  const els = {
15
19
  layout: $('#layout'),
16
20
  list: $('#list'),
@@ -25,9 +29,32 @@ const els = {
25
29
  tagFilter: $('#tag-filter'),
26
30
  tagFilterName: $('#tag-filter-name'),
27
31
  tagClear: $('#tag-clear'),
32
+ selectionToolbar: $('#selection-toolbar'),
33
+ selectionQuote: $('#selection-quote'),
34
+ selectionNote: $('#selection-note'),
28
35
  toast: $('#toast'),
29
36
  }
30
37
 
38
+ function codePointLength(value) {
39
+ return Array.from(String(value ?? '')).length
40
+ }
41
+
42
+ function codePointSlice(value, start, end) {
43
+ return Array.from(String(value ?? '')).slice(start, end).join('')
44
+ }
45
+
46
+ function codePointToUtf16(value, index) {
47
+ let codePoints = 0
48
+ let offset = 0
49
+ while (offset < value.length && codePoints < index) {
50
+ const code = value.charCodeAt(offset)
51
+ if (code >= 0xd800 && code <= 0xdbff && offset + 1 < value.length) offset += 1
52
+ offset += 1
53
+ codePoints += 1
54
+ }
55
+ return offset
56
+ }
57
+
31
58
  function escapeHtml(value) {
32
59
  return String(value ?? '')
33
60
  .replaceAll('&', '&amp;')
@@ -163,6 +190,7 @@ function renderList() {
163
190
  <span>${statusLabel(item.status)}</span>
164
191
  <span>·</span>
165
192
  <span>${fmtWords(item.wordCount)}</span>
193
+ ${item.annotationCount > 0 ? `<span>·</span><span>${item.annotationCount} 批注</span>` : ''}
166
194
  ${item.tags.slice(0, 3).map(tagButton).join('')}
167
195
  </div>
168
196
  `
@@ -200,7 +228,216 @@ function updateSelectedInList() {
200
228
  }
201
229
  }
202
230
 
231
+ function annotationColorButtons(current, annotationId) {
232
+ return ANNOTATION_COLORS.map(color => `
233
+ <button type="button" class="color-dot ${color}${color === current ? ' active' : ''}"
234
+ data-action="annotation-color" data-color="${color}" data-annotation-id="${escapeAttr(annotationId)}"
235
+ aria-label="${color}"></button>`).join('')
236
+ }
237
+
238
+ function renderAnnotationSection(annotations) {
239
+ const list = Array.isArray(annotations) ? annotations : []
240
+ const items = list.map(annotation => {
241
+ const stale = annotation.status === 'stale'
242
+ return `
243
+ <article class="annotation-item${stale ? ' stale' : ''}" data-annotation-id="${escapeAttr(annotation.id)}">
244
+ <div class="annotation-top">
245
+ <span class="color-dot ${escapeAttr(annotation.color || 'yellow')}"></span>
246
+ <span class="annotation-status">${stale ? '原文已变化,未能定位' : '已定位'}</span>
247
+ <span class="annotation-spacer"></span>
248
+ ${stale ? '' : '<button type="button" class="button small" data-action="jump-annotation">定位</button>'}
249
+ <button type="button" class="button small danger" data-action="delete-annotation">删除</button>
250
+ </div>
251
+ <blockquote>${escapeHtml(annotation.quote)}</blockquote>
252
+ <div class="annotation-note-row">
253
+ <input class="annotation-note" data-annotation-id="${escapeAttr(annotation.id)}"
254
+ value="${escapeAttr(annotation.note || '')}" placeholder="写批注…" maxlength="2000">
255
+ <button type="button" class="button small" data-action="save-annotation-note">保存</button>
256
+ </div>
257
+ <div class="annotation-colors">${annotationColorButtons(annotation.color || 'yellow', annotation.id)}</div>
258
+ </article>`
259
+ }).join('')
260
+ return `
261
+ <section class="annotation-section" id="annotations">
262
+ <div class="annotation-head">
263
+ <h3>批注 <span>${list.length}</span></h3>
264
+ <p>${list.length === 0 ? '选中正文文字即可高亮、写批注。' : '点击批注定位到原文;导出 Markdown 时会一起带上。'}</p>
265
+ </div>
266
+ ${items || '<div class="annotation-empty">还没有批注。</div>'}
267
+ </section>`
268
+ }
269
+
270
+ function wrapCodePointRange(root, start, end, annotation) {
271
+ const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT)
272
+ const nodes = []
273
+ let position = 0
274
+ let node
275
+ while ((node = walker.nextNode()) !== null) {
276
+ const length = codePointLength(node.data)
277
+ nodes.push({ node, start: position, end: position + length })
278
+ position += length
279
+ }
280
+
281
+ for (const entry of nodes) {
282
+ if (entry.end <= start || entry.start >= end) continue
283
+ const localStart = Math.max(0, start - entry.start)
284
+ const localEnd = Math.min(entry.end - entry.start, end - entry.start)
285
+ if (localEnd <= localStart) continue
286
+
287
+ let target = entry.node
288
+ const utf16Start = codePointToUtf16(target.data, localStart)
289
+ const utf16End = codePointToUtf16(target.data, localEnd)
290
+ if (utf16Start > 0) target = target.splitText(utf16Start)
291
+ if (utf16End - utf16Start < target.data.length) target.splitText(utf16End - utf16Start)
292
+ if (target.data === '') continue
293
+
294
+ const mark = document.createElement('mark')
295
+ mark.className = `hl hl-${annotation.color || 'yellow'}`
296
+ mark.dataset.annotationId = annotation.id
297
+ if (annotation.note) mark.title = annotation.note
298
+ target.parentNode.insertBefore(mark, target)
299
+ mark.append(target)
300
+ }
301
+ }
302
+
303
+ function applyHighlights(root, annotations) {
304
+ if (!root) return
305
+ const active = (Array.isArray(annotations) ? annotations : [])
306
+ .filter(annotation => annotation.status !== 'stale' && annotation.startOffset >= 0 && annotation.endOffset > annotation.startOffset)
307
+ .sort((a, b) => a.startOffset - b.startOffset)
308
+ for (const annotation of active) {
309
+ wrapCodePointRange(root, annotation.startOffset, annotation.endOffset, annotation)
310
+ }
311
+ }
312
+
313
+ function focusAnnotation(annotationId) {
314
+ const target = els.detail.querySelector(`.annotation-item[data-annotation-id="${CSS.escape(annotationId)}"]`)
315
+ if (target === null) return
316
+ target.scrollIntoView({ block: 'nearest', behavior: 'smooth' })
317
+ target.classList.add('pulse')
318
+ setTimeout(() => target.classList.remove('pulse'), 1200)
319
+ }
320
+
321
+ function scrollToAnnotation(annotationId) {
322
+ const mark = els.detail.querySelector(`.article mark[data-annotation-id="${CSS.escape(annotationId)}"]`)
323
+ if (mark === null) {
324
+ focusAnnotation(annotationId)
325
+ return
326
+ }
327
+ mark.scrollIntoView({ block: 'center', behavior: 'smooth' })
328
+ mark.classList.add('pulse')
329
+ setTimeout(() => mark.classList.remove('pulse'), 1200)
330
+ }
331
+
332
+ function hideSelectionToolbar() {
333
+ if (!els.selectionToolbar) return
334
+ els.selectionToolbar.hidden = true
335
+ state.selection = null
336
+ state.selectionColor = 'yellow'
337
+ if (els.selectionNote) els.selectionNote.value = ''
338
+ }
339
+
340
+ function captureSelection() {
341
+ const article = els.detail.querySelector('.article')
342
+ if (!article) return null
343
+ const selection = window.getSelection()
344
+ if (!selection || selection.rangeCount === 0 || selection.isCollapsed) return null
345
+ const range = selection.getRangeAt(0)
346
+ if (!article.contains(range.startContainer) || !article.contains(range.endContainer)) return null
347
+
348
+ const fullText = article.textContent
349
+ const before = document.createRange()
350
+ before.selectNodeContents(article)
351
+ before.setEnd(range.startContainer, range.startOffset)
352
+ const after = document.createRange()
353
+ after.selectNodeContents(article)
354
+ after.setStart(range.endContainer, range.endOffset)
355
+
356
+ let start = codePointLength(before.toString())
357
+ let end = codePointLength(fullText) - codePointLength(after.toString())
358
+ if (end <= start) return null
359
+
360
+ while (start < end && /\s/.test(codePointSlice(fullText, start, start + 1))) start += 1
361
+ while (end > start && /\s/.test(codePointSlice(fullText, end - 1, end))) end -= 1
362
+ const quote = codePointSlice(fullText, start, end)
363
+ if (quote.trim() === '') return null
364
+
365
+ return {
366
+ quote,
367
+ startOffset: start,
368
+ endOffset: end,
369
+ prefix: codePointSlice(fullText, Math.max(0, start - 32), start),
370
+ suffix: codePointSlice(fullText, end, end + 32),
371
+ rect: range.getBoundingClientRect(),
372
+ }
373
+ }
374
+
375
+ function showSelectionToolbar(selection) {
376
+ if (!els.selectionToolbar) return
377
+ state.selection = selection
378
+ state.selectionColor = 'yellow'
379
+ els.selectionQuote.textContent = `“${selection.quote.slice(0, 140)}${selection.quote.length > 140 ? '…' : ''}”`
380
+ els.selectionNote.value = ''
381
+ for (const dot of els.selectionToolbar.querySelectorAll('[data-color]')) {
382
+ dot.classList.toggle('active', dot.dataset.color === 'yellow')
383
+ }
384
+ els.selectionToolbar.hidden = false
385
+ const width = els.selectionToolbar.offsetWidth
386
+ const height = els.selectionToolbar.offsetHeight
387
+ const rect = selection.rect
388
+ const left = Math.min(
389
+ Math.max(8, rect.left + rect.width / 2 - width / 2),
390
+ window.innerWidth - width - 8,
391
+ )
392
+ const top = rect.bottom + height + 12 > window.innerHeight
393
+ ? Math.max(8, rect.top - height - 8)
394
+ : rect.bottom + 8
395
+ els.selectionToolbar.style.left = `${left}px`
396
+ els.selectionToolbar.style.top = `${top}px`
397
+ }
398
+
399
+ function updateSelectionToolbar() {
400
+ const selection = captureSelection()
401
+ if (selection === null) {
402
+ hideSelectionToolbar()
403
+ return
404
+ }
405
+ showSelectionToolbar(selection)
406
+ }
407
+
408
+ async function saveSelectionAnnotation() {
409
+ const item = state.selected
410
+ const selection = state.selection
411
+ if (item === null || selection === null) return
412
+ const button = els.selectionToolbar?.querySelector('[data-action="save-highlight"]')
413
+ if (button) button.disabled = true
414
+ try {
415
+ await api(`/items/${encodeURIComponent(item.id)}/annotations`, {
416
+ method: 'POST',
417
+ body: JSON.stringify({
418
+ quote: selection.quote,
419
+ startOffset: selection.startOffset,
420
+ endOffset: selection.endOffset,
421
+ prefix: selection.prefix,
422
+ suffix: selection.suffix,
423
+ color: state.selectionColor,
424
+ note: els.selectionNote?.value ?? '',
425
+ }),
426
+ })
427
+ window.getSelection()?.removeAllRanges()
428
+ hideSelectionToolbar()
429
+ toast('已添加批注')
430
+ await select(item.id)
431
+ await loadList()
432
+ } catch (error) {
433
+ toast(error.message, true)
434
+ } finally {
435
+ if (button) button.disabled = false
436
+ }
437
+ }
438
+
203
439
  function renderDetail() {
440
+ hideSelectionToolbar()
204
441
  const item = state.selected
205
442
  if (item === null) {
206
443
  els.detail.innerHTML = `
@@ -217,6 +454,10 @@ function renderDetail() {
217
454
  const author = item.author ? `<span>${escapeHtml(item.author)}</span><span>·</span>` : ''
218
455
  const published = item.published ? `<span>${escapeHtml(item.published.slice(0, 10))}</span><span>·</span>` : ''
219
456
  const truncated = item.truncated ? '<p class="article-note">原文较长,保存时已截断。</p>' : ''
457
+ const annotations = Array.isArray(item.annotations) ? item.annotations : []
458
+ const annotationMeta = annotations.length > 0
459
+ ? `<span>·</span><span>${annotations.length} 批注</span>`
460
+ : ''
220
461
 
221
462
  els.detail.innerHTML = `
222
463
  <div class="detail-head">
@@ -224,7 +465,7 @@ function renderDetail() {
224
465
  <span>${escapeHtml(item.site || '未命名来源')}</span><span>·</span>
225
466
  <span>${fmtDate(item.clippedAt)}</span><span>·</span>
226
467
  <span>${fmtWords(item.wordCount)}</span><span>·</span>
227
- <span>${statusLabel(item.status)}</span>
468
+ <span>${statusLabel(item.status)}</span>${annotationMeta}
228
469
  </div>
229
470
  <h2>${escapeHtml(item.title)}</h2>
230
471
  <div class="detail-sub">
@@ -245,7 +486,10 @@ function renderDetail() {
245
486
  </div>
246
487
  </div>
247
488
  <article class="article">${item.html}${truncated}</article>
489
+ ${renderAnnotationSection(annotations)}
248
490
  `
491
+
492
+ applyHighlights(els.detail.querySelector('.article'), annotations)
249
493
  }
250
494
 
251
495
  async function select(id) {
@@ -378,10 +622,17 @@ els.detail.addEventListener('click', async event => {
378
622
  setTag(tag.dataset.tag)
379
623
  return
380
624
  }
625
+ const mark = event.target.closest('mark[data-annotation-id]')
626
+ if (mark !== null) {
627
+ focusAnnotation(mark.dataset.annotationId)
628
+ return
629
+ }
381
630
  const action = event.target.closest('[data-action]')?.dataset.action
382
631
  if (action === undefined) return
383
632
  const item = state.selected
384
633
  if (item === null) return
634
+ const annotationItem = event.target.closest('.annotation-item')
635
+ const annotationId = annotationItem?.dataset.annotationId
385
636
 
386
637
  if (action === 'back') {
387
638
  els.layout.classList.remove('detail-open')
@@ -408,7 +659,96 @@ els.detail.addEventListener('click', async event => {
408
659
  const input = $('#tag-edit')
409
660
  const tags = (input?.value ?? '').split(/[,,]/).map(value => value.trim()).filter(Boolean)
410
661
  await updateItem(item.id, { tags })
662
+ return
663
+ }
664
+ if (action === 'jump-annotation') {
665
+ if (annotationId !== undefined) scrollToAnnotation(annotationId)
666
+ return
411
667
  }
668
+ if (action === 'delete-annotation') {
669
+ if (annotationId === undefined) return
670
+ try {
671
+ await api(`/items/${encodeURIComponent(item.id)}/annotations/${encodeURIComponent(annotationId)}`, {
672
+ method: 'DELETE',
673
+ })
674
+ toast('已删除批注')
675
+ await select(item.id)
676
+ await loadList()
677
+ } catch (error) {
678
+ toast(error.message, true)
679
+ }
680
+ return
681
+ }
682
+ if (action === 'save-annotation-note') {
683
+ if (annotationId === undefined) return
684
+ const note = annotationItem.querySelector('.annotation-note')?.value ?? ''
685
+ try {
686
+ await api(`/items/${encodeURIComponent(item.id)}/annotations/${encodeURIComponent(annotationId)}`, {
687
+ method: 'PATCH',
688
+ body: JSON.stringify({ note }),
689
+ })
690
+ toast('批注已保存')
691
+ await select(item.id)
692
+ await loadList()
693
+ } catch (error) {
694
+ toast(error.message, true)
695
+ }
696
+ return
697
+ }
698
+ if (action === 'annotation-color') {
699
+ if (annotationId === undefined) return
700
+ const color = event.target.closest('[data-color]')?.dataset.color
701
+ if (color === undefined) return
702
+ try {
703
+ await api(`/items/${encodeURIComponent(item.id)}/annotations/${encodeURIComponent(annotationId)}`, {
704
+ method: 'PATCH',
705
+ body: JSON.stringify({ color }),
706
+ })
707
+ toast('颜色已更新')
708
+ await select(item.id)
709
+ await loadList()
710
+ } catch (error) {
711
+ toast(error.message, true)
712
+ }
713
+ }
714
+ })
715
+
716
+ if (els.selectionToolbar !== null) {
717
+ els.selectionToolbar.addEventListener('mousedown', event => {
718
+ if (event.target.closest('button') !== null) event.preventDefault()
719
+ })
720
+ els.selectionToolbar.addEventListener('click', event => {
721
+ const color = event.target.closest('[data-color]')?.dataset.color
722
+ if (color !== undefined) {
723
+ state.selectionColor = color
724
+ for (const dot of els.selectionToolbar.querySelectorAll('[data-color]')) {
725
+ dot.classList.toggle('active', dot.dataset.color === color)
726
+ }
727
+ return
728
+ }
729
+ const action = event.target.closest('[data-action]')?.dataset.action
730
+ if (action === 'save-highlight') saveSelectionAnnotation()
731
+ })
732
+ }
733
+
734
+ let selectionTimer
735
+ els.detail.addEventListener('mouseup', () => {
736
+ clearTimeout(selectionTimer)
737
+ selectionTimer = setTimeout(updateSelectionToolbar, 0)
738
+ })
739
+ els.detail.addEventListener('keyup', event => {
740
+ if (!event.shiftKey) return
741
+ clearTimeout(selectionTimer)
742
+ selectionTimer = setTimeout(updateSelectionToolbar, 0)
743
+ })
744
+ els.detail.addEventListener('scroll', hideSelectionToolbar, { passive: true })
745
+ window.addEventListener('resize', hideSelectionToolbar)
746
+ els.detail.addEventListener('keydown', event => {
747
+ if (event.key !== 'Enter') return
748
+ const input = event.target.closest?.('.annotation-note')
749
+ if (input === null || input === undefined) return
750
+ event.preventDefault()
751
+ input.closest('.annotation-item')?.querySelector('[data-action="save-annotation-note"]')?.click()
412
752
  })
413
753
 
414
754
  document.addEventListener('keydown', event => {
@@ -420,6 +760,7 @@ document.addEventListener('keydown', event => {
420
760
  return
421
761
  }
422
762
  if (event.key === 'Escape') {
763
+ hideSelectionToolbar()
423
764
  if (document.activeElement === els.search) {
424
765
  els.search.value = ''
425
766
  state.q = ''
package/web/index.html CHANGED
@@ -56,6 +56,18 @@
56
56
  </main>
57
57
  </div>
58
58
 
59
+ <div id="selection-toolbar" class="selection-toolbar" hidden>
60
+ <div class="selection-quote" id="selection-quote"></div>
61
+ <div class="selection-controls">
62
+ <button type="button" class="color-dot yellow active" data-color="yellow" aria-label="黄色高亮"></button>
63
+ <button type="button" class="color-dot green" data-color="green" aria-label="绿色高亮"></button>
64
+ <button type="button" class="color-dot blue" data-color="blue" aria-label="蓝色高亮"></button>
65
+ <button type="button" class="color-dot red" data-color="red" aria-label="红色高亮"></button>
66
+ <input id="selection-note" type="text" maxlength="2000" placeholder="批注(可选)">
67
+ <button type="button" class="button primary" data-action="save-highlight">保存高亮</button>
68
+ </div>
69
+ </div>
70
+
59
71
  <div id="toast" class="toast" role="status" hidden></div>
60
72
  <script src="./app.js" type="module"></script>
61
73
  </body>
package/web/style.css CHANGED
@@ -572,3 +572,168 @@ button.primary:disabled { opacity: .55; cursor: default; }
572
572
  .article { padding: 18px 16px 70px; font-size: 15px; }
573
573
  .mobile-back { display: inline-flex; }
574
574
  }
575
+
576
+ .selection-toolbar {
577
+ position: fixed;
578
+ z-index: 60;
579
+ display: flex;
580
+ flex-direction: column;
581
+ gap: 8px;
582
+ width: min(390px, calc(100vw - 24px));
583
+ padding: 10px;
584
+ border: 1px solid var(--border);
585
+ border-radius: 12px;
586
+ background: var(--panel);
587
+ box-shadow: 0 12px 32px rgba(16, 24, 40, .18);
588
+ }
589
+
590
+ .selection-toolbar[hidden] { display: none; }
591
+
592
+ .selection-quote {
593
+ padding-left: 8px;
594
+ border-left: 3px solid var(--accent);
595
+ color: var(--muted);
596
+ font-size: 12px;
597
+ line-height: 1.45;
598
+ max-height: 44px;
599
+ overflow: hidden;
600
+ }
601
+
602
+ .selection-controls {
603
+ display: flex;
604
+ align-items: center;
605
+ gap: 6px;
606
+ flex-wrap: wrap;
607
+ }
608
+
609
+ .color-dot {
610
+ display: inline-block;
611
+ width: 18px;
612
+ height: 18px;
613
+ padding: 0;
614
+ border: 2px solid transparent;
615
+ border-radius: 50%;
616
+ flex: none;
617
+ }
618
+
619
+ .color-dot.active {
620
+ border-color: var(--text);
621
+ box-shadow: 0 0 0 2px var(--panel);
622
+ transform: scale(1.08);
623
+ }
624
+
625
+ .color-dot.yellow { background: #facc15; }
626
+ .color-dot.green { background: #22c55e; }
627
+ .color-dot.blue { background: #3b82f6; }
628
+ .color-dot.red { background: #ef4444; }
629
+
630
+ #selection-note {
631
+ flex: 1 1 140px;
632
+ min-width: 0;
633
+ height: 30px;
634
+ padding: 0 8px;
635
+ border: 1px solid var(--border);
636
+ border-radius: 8px;
637
+ background: var(--panel-2);
638
+ }
639
+
640
+ .annotation-section { padding: 0 30px 42px; }
641
+
642
+ .annotation-head {
643
+ display: flex;
644
+ align-items: baseline;
645
+ justify-content: space-between;
646
+ gap: 12px;
647
+ margin-top: 8px;
648
+ padding-top: 18px;
649
+ border-top: 1px solid var(--border);
650
+ }
651
+
652
+ .annotation-head h3 { margin: 0; font-size: 15px; }
653
+ .annotation-head h3 span { color: var(--muted); font-weight: 400; }
654
+ .annotation-head p { margin: 0; color: var(--muted); font-size: 12px; }
655
+
656
+ .annotation-empty { padding: 12px 0; color: var(--muted); font-size: 13px; }
657
+
658
+ .annotation-item {
659
+ margin: 10px 0;
660
+ padding: 10px 12px;
661
+ border: 1px solid var(--border);
662
+ border-radius: 10px;
663
+ background: var(--panel);
664
+ }
665
+
666
+ .annotation-item.stale { opacity: .72; }
667
+ .annotation-item.pulse { animation: annotationPulse 1.1s ease; }
668
+
669
+ .annotation-top {
670
+ display: flex;
671
+ align-items: center;
672
+ gap: 8px;
673
+ color: var(--muted);
674
+ font-size: 11px;
675
+ }
676
+
677
+ .annotation-top .color-dot { width: 14px; height: 14px; }
678
+ .annotation-spacer { flex: 1; }
679
+
680
+ .annotation-item blockquote {
681
+ margin: 8px 0;
682
+ padding: 6px 10px;
683
+ border-left: 3px solid var(--border);
684
+ color: var(--text);
685
+ font-size: 13px;
686
+ line-height: 1.6;
687
+ }
688
+
689
+ .annotation-note-row { display: flex; gap: 6px; }
690
+
691
+ .annotation-note {
692
+ flex: 1;
693
+ min-width: 0;
694
+ height: 30px;
695
+ padding: 0 8px;
696
+ border: 1px solid var(--border);
697
+ border-radius: 8px;
698
+ background: var(--panel-2);
699
+ }
700
+
701
+ .annotation-colors { display: flex; gap: 5px; margin-top: 7px; }
702
+
703
+ .button.small { height: 26px; padding: 0 8px; font-size: 12px; }
704
+ .button.danger { color: #b42318; border-color: #f3c7c4; }
705
+
706
+ mark.hl {
707
+ padding: 0 1px;
708
+ border-radius: 3px;
709
+ color: inherit;
710
+ cursor: pointer;
711
+ }
712
+
713
+ .hl-yellow { background: #fef08a; }
714
+ .hl-green { background: #bbf7d0; }
715
+ .hl-blue { background: #bfdbfe; }
716
+ .hl-red { background: #fecaca; }
717
+
718
+ @media (prefers-color-scheme: dark) {
719
+ .hl-yellow { background: rgba(250, 204, 21, .34); }
720
+ .hl-green { background: rgba(34, 197, 94, .30); }
721
+ .hl-blue { background: rgba(59, 130, 246, .32); }
722
+ .hl-red { background: rgba(239, 68, 68, .32); }
723
+ }
724
+
725
+ @keyframes annotationPulse {
726
+ 0%, 100% { box-shadow: 0 0 0 0 transparent; }
727
+ 35% { box-shadow: 0 0 0 3px var(--accent-soft); }
728
+ }
729
+
730
+ @media (max-width: 820px) {
731
+ .annotation-section { padding: 0 16px 70px; }
732
+ .annotation-head { flex-direction: column; align-items: flex-start; gap: 4px; }
733
+ .selection-toolbar { width: calc(100vw - 24px); }
734
+ }
735
+
736
+ mark.hl.pulse {
737
+ outline: 2px solid var(--accent);
738
+ outline-offset: 1px;
739
+ }