/* Annotations overlay styles */

.ann {
  border-radius: 0.15em;
  padding: 0 0.1em;
  margin: 0 -0.05em;
}

.ann--strikethrough {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  background-color: #fee2e2;
  color: #7f1d1d;
}

.ann--comment {
  position: relative;
  background-color: #fef9c3;
  box-shadow: 0 0 0 1px #facc15 inset;
}

.ann--resolved {
  opacity: 0.45;
  background-color: #f3f4f6 !important;
  box-shadow: none !important;
  text-decoration-color: #9ca3af;
}

.ann-marker {
  display: inline-block;
  font-size: 0.7em;
  vertical-align: super;
  line-height: 1;
  margin-left: 0.15em;
  color: #b45309;
  cursor: help;
}

/* Selection toolbar */
#ann-toolbar {
  position: absolute;
  z-index: 9000;
  display: none;
  background: #1e3a8a;
  color: white;
  border-radius: 0.375rem;
  padding: 0.25rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  font-size: 0.875rem;
  user-select: none;
}

#ann-toolbar.is-visible {
  display: flex;
  gap: 0.25rem;
}

#ann-toolbar button {
  background: transparent;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 0.25rem;
  padding: 0.35rem 0.6rem;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
}

#ann-toolbar button:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Comment prompt */
#ann-prompt-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9500;
}

#ann-prompt-backdrop.is-visible {
  display: flex;
}

.ann-prompt {
  background: white;
  border-radius: 0.5rem;
  padding: 1.25rem;
  width: min(520px, 92vw);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.ann-prompt h3 {
  margin: 0 0 0.5rem;
  color: #1e3a8a;
  font-size: 1.1rem;
}

.ann-prompt .ann-snippet {
  background: #f3f4f6;
  border-left: 3px solid #1e3a8a;
  padding: 0.5rem 0.75rem;
  margin: 0.5rem 0;
  font-size: 0.85rem;
  color: #374151;
  max-height: 6em;
  overflow: auto;
  border-radius: 0.25rem;
  white-space: pre-wrap;
}

.ann-prompt textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 5rem;
  resize: vertical;
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 0.25rem;
}

.ann-prompt .ann-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.ann-prompt button {
  padding: 0.5rem 0.9rem;
  border-radius: 0.25rem;
  border: 1px solid transparent;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
}

.ann-prompt .ann-cancel {
  background: white;
  color: #374151;
  border-color: #d1d5db;
}

.ann-prompt .ann-save {
  background: #1e3a8a;
  color: white;
}

.ann-prompt .ann-delete {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fecaca;
  margin-right: auto;
}

/* Sidebar */
#annotation-sidebar {
  position: fixed;
  top: 7.5rem;
  right: 1rem;
  width: 320px;
  max-height: calc(100vh - 9rem);
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
  display: none;
  flex-direction: column;
  z-index: 100;
  font-size: 0.9rem;
}

#annotation-sidebar.is-visible {
  display: flex;
}

#annotation-sidebar .ann-side-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid #e5e7eb;
  background: #1e3a8a;
  color: white;
  border-top-left-radius: 0.5rem;
  border-top-right-radius: 0.5rem;
}

#annotation-sidebar .ann-side-header strong {
  font-size: 0.95rem;
}

#annotation-sidebar .ann-side-header-actions {
  display: flex;
  gap: 0.35rem;
}

#annotation-sidebar .ann-side-header button {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: none;
  padding: 0.25rem 0.55rem;
  border-radius: 0.25rem;
  cursor: pointer;
  font-size: 0.75rem;
}

#annotation-sidebar .ann-side-header button:hover {
  background: rgba(255, 255, 255, 0.3);
}

#annotation-sidebar .ann-side-footer {
  padding: 0.5rem 0.75rem;
  border-top: 1px solid #e5e7eb;
  font-size: 0.7rem;
  background: #fafafa;
  border-bottom-left-radius: 0.5rem;
  border-bottom-right-radius: 0.5rem;
}

#annotation-sidebar .ann-mode-synced {
  color: #15803d;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

#annotation-sidebar .ann-mode-synced::before {
  content: '●';
  color: #22c55e;
}

#annotation-sidebar .ann-mode-local-only {
  color: #92400e;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

#annotation-sidebar .ann-mode-local-only::before {
  content: '◐';
  color: #f59e0b;
}

.ann-src {
  display: inline-block;
  font-size: 0.65rem;
  background: #fef3c7;
  color: #92400e;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  margin-left: 0.25rem;
  font-style: normal;
}

/* Toast banners */
.ann-banner {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: #1e3a8a;
  color: white;
  padding: 0.6rem 1rem;
  border-radius: 0.375rem;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
  font-size: 0.9rem;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

.ann-banner.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.ann-banner-ok {
  background: #15803d;
}

.ann-banner-err {
  background: #b91c1c;
}

#annotation-sidebar .ann-side-body {
  overflow-y: auto;
  padding: 0.5rem;
  flex: 1;
}

#annotation-sidebar .ann-empty {
  padding: 1rem;
  color: #6b7280;
  font-size: 0.85rem;
  text-align: center;
}

#annotation-sidebar .ann-item {
  border: 1px solid #e5e7eb;
  border-radius: 0.375rem;
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  background: #fafafa;
  transition: background 0.15s, border-color 0.15s;
}

#annotation-sidebar .ann-item:hover {
  background: #f3f4f6;
  border-color: #cbd5e1;
}

#annotation-sidebar .ann-item.is-active {
  border-color: #1e3a8a;
  background: #eff6ff;
}

#annotation-sidebar .ann-item.is-resolved {
  opacity: 0.55;
}

#annotation-sidebar .ann-snippet-mini {
  font-size: 0.78rem;
  color: #4b5563;
  margin-bottom: 0.3rem;
  font-style: italic;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

#annotation-sidebar .ann-comment {
  font-size: 0.85rem;
  color: #1f2937;
  margin-bottom: 0.35rem;
  white-space: pre-wrap;
}

#annotation-sidebar .ann-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.7rem;
  color: #6b7280;
}

#annotation-sidebar .ann-actions-mini button {
  background: transparent;
  border: none;
  color: #1e3a8a;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0 0.25rem;
}

#annotation-sidebar .ann-actions-mini button:hover {
  text-decoration: underline;
}

#annotation-sidebar .ann-resolved-label {
  font-size: 0.7rem;
  color: #6b7280;
  margin-top: 0.2rem;
}

/* Floating toggle button */
#ann-toggle {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  background: #1e3a8a;
  color: white;
  border: none;
  border-radius: 999px;
  padding: 0.6rem 0.9rem;
  box-shadow: 0 6px 14px rgba(30, 58, 138, 0.4);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  z-index: 99;
  display: none;
}

#ann-toggle.is-visible {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

#ann-toggle .ann-count {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 0 0.45rem;
  font-size: 0.75rem;
}

/* Reflow content when sidebar open */
body.has-ann-sidebar main.container,
body.has-ann-sidebar .container {
  transition: max-width 0.2s ease;
}

@media (min-width: 1100px) {
  body.has-ann-sidebar main.container {
    margin-right: 340px;
  }
}

@media (max-width: 1099px) {
  #annotation-sidebar {
    top: auto;
    bottom: 4rem;
    right: 0.5rem;
    left: 0.5rem;
    width: auto;
  }
}