.reader-annotation-layer { position: absolute; inset: 0; z-index: 3; direction: ltr; pointer-events: none; }
.reader-annotation-layer[hidden] { display: none; }
.book-reader.is-annotating .reader-annotation-layer { pointer-events: auto; cursor: text; }
.book-reader .reader-annotation-card {
  position: absolute;
  min-height: 32px;
  border: 1px solid #cfdbc8;
  border-radius: 5px;
  background: #f7faefee;
  color: #2a4637;
  box-shadow: 0 2px 6px #26392e12;
  pointer-events: auto;
  cursor: default;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
.book-reader .reader-annotation-text {
  display: block;
  width: 100%;
  min-height: 30px;
  max-height: inherit;
  margin: 0;
  padding: 6px 8px 6px 30px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow: auto;
  overscroll-behavior: contain;
  text-align: start;
  font-family: 'Noto Sans Arabic', sans-serif;
  font-size: var(--annotation-font-size, 16px);
  line-height: 1.7;
  touch-action: pan-x pan-y pinch-zoom;
}
.book-reader .reader-annotation-drag {
  position: absolute;
  top: 3px;
  left: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  min-width: 0;
  margin: 0;
  padding: 4px;
  border: 0;
  border-radius: 4px;
  background: #e4edda;
  color: #486543;
  cursor: grab;
  touch-action: none;
}
.reader-annotation-drag::after { content: ''; position: absolute; inset: -10px; }
.reader-annotation-drag svg { width: 16px; height: 16px; }
.book-reader .reader-annotation-card.is-moving { opacity: .8; outline: 2px solid #91b185; box-shadow: 0 4px 15px #26392e30; }
.book-reader .reader-annotation-card.is-moving .reader-annotation-drag { cursor: grabbing; }
.book-reader .reader-view-controls .reader-annotation-button {
  width: auto;
  min-width: 100px;
  height: 44px;
  padding: 8px 10px;
  gap: 6px;
  border: 1px solid var(--border, #dfdfd2);
  background: var(--card, #faf8f2);
  font-size: 12px;
  white-space: nowrap;
}
.book-reader .reader-annotation-button[aria-pressed=true] { background: #dfecda; border-color: #91b185; color: #2a4a2d; }
.book-reader .reader-annotation-help {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 3px 14px;
  padding: 7px 28px;
  border-top: 1px solid var(--border, #dfdfd2);
  color: var(--ink, #26392e);
  font-size: 11px;
  line-height: 1.8;
}
.book-reader .reader-annotation-help[hidden] { display: none; }
.reader-annotation-status { color: var(--muted, #7a7c70); }
.reader-annotation-editor {
  position: fixed;
  z-index: 35;
  display: flex;
  flex-direction: column;
  direction: rtl;
  gap: 8px;
  width: 330px;
  padding: 12px;
  border: 1px solid var(--border, #dfdfd2);
  border-radius: 9px;
  background: var(--card, #faf8f2);
  color: var(--ink, #26392e);
  box-shadow: 0 5px 22px #26392e25;
  overflow: auto;
  overscroll-behavior: contain;
  font-family: 'Noto Sans Arabic', sans-serif;
  user-select: text;
  -webkit-user-select: text;
}
.reader-annotation-editor label { font-size: 13px; line-height: 1.8; }
.book-reader .reader-annotation-editor textarea {
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-height: 88px;
  max-height: 180px;
  resize: vertical;
  padding: 9px;
  border: 1px solid var(--border, #dfdfd2);
  border-radius: 6px;
  background: var(--paper, #f7f4ec);
  color: inherit;
  font: inherit;
  font-size: 16px;
  line-height: 1.8;
  user-select: text;
  -webkit-user-select: text;
  touch-action: auto;
}
.reader-annotation-editor textarea:focus-visible { outline: 2px solid var(--reader-accent, #596342); outline-offset: 1px; }
.reader-annotation-count { color: var(--muted, #7a7c70); font-size: 10px; direction: rtl; text-align: left; }
.reader-annotation-error { color: var(--ink, #26392e); font-size: 11px; line-height: 1.8; }
.reader-annotation-error:empty { display: none; }
.reader-annotation-editor-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.book-reader .reader-annotation-editor-actions button {
  min-height: 44px;
  padding: 8px 11px;
  border: 1px solid var(--border, #dfdfd2);
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 12px;
}
.book-reader .reader-annotation-editor-actions .reader-annotation-save { background: #dfecda; border-color: #91b185; color: #2a4a2d; }
.book-reader .reader-annotation-editor-actions .reader-annotation-delete { margin-inline-start: auto; }
.book-reader.is-dragging-annotation .reader-stage { scroll-behavior: auto; }
html[data-theme=dark] .book-reader .reader-annotation-button[aria-pressed=true] { background: #344d33; border-color: #6e9864; color: #e2f0dd; }
@media (max-width: 640px), (max-width: 999px) and (max-height: 500px) and (orientation: landscape) {
  .book-reader .reader-view-controls .reader-annotation-button { flex: 0 0 44px; min-width: 44px; max-width: 44px; width: 44px; padding: 10px; }
  .book-reader .reader-annotation-button span { display: none; }
  .book-reader .reader-annotation-help { padding: 4px 12px; font-size: 10px; }
  .book-reader .reader-annotation-card { min-height: 44px; }
  .book-reader .reader-annotation-text { min-height: 42px; padding-left: 50px; }
  .book-reader .reader-annotation-drag { top: 0; left: 0; width: 44px; height: 44px; padding: 12px; }
  .reader-annotation-drag::after { display: none; }
  .reader-annotation-drag svg { width: 20px; height: 20px; }
}
@media (prefers-reduced-motion: reduce) { .reader-annotation-card { transition: none; } }
