/* ── Viewer layout ─────────────────────────────────────────────────────── */
#viewer-root {
  font-family: 'Georgia', 'Times New Roman', serif;
  line-height: 1.8;
}

.viewer-shell {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 2rem;
  min-height: calc(100vh - 160px);
}

@media (max-width: 900px) {
  .viewer-shell {
    grid-template-columns: 1fr;
  }
  .viewer-sidebar {
    order: -1;
  }
}

/* ── Document area ─────────────────────────────────────────────────────── */
.viewer-doc {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 3rem 3.5rem;
  max-width: 100%;
}

.viewer-doc h1 {
  font-size: 1.4rem;
  font-weight: 600;
  color: #111827;
  margin-bottom: 0.5rem;
  font-family: system-ui, sans-serif;
}

.viewer-doc .doc-meta {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-bottom: 2rem;
  font-family: system-ui, sans-serif;
}

.viewer-doc p {
  color: #1f2937;
  margin-bottom: 1.25rem;
  font-size: 0.975rem;
}

/* ── Annotation spans ──────────────────────────────────────────────────── */
.ann {
  position: relative;
  border-radius: 2px;
  cursor: default;
  transition: filter 0.15s;
}

.ann:hover {
  filter: brightness(0.93);
}

/* AI suggested — user modified it (used by the static demo renderer) */
.ann-ai-revised {
  background-color: #dbeafe;
  border-bottom: 2px solid #3b82f6;
}

/* AI suggested — unmodified (accepted as-is) (demo renderer) */
.ann-ai-unmodified {
  background-color: #fef9c3;
  border-bottom: 2px solid #f59e0b;
}

/* Pasted content / source cited (demo renderer) */
.ann-source {
  background-color: #dcfce7;
  border-bottom: 2px solid #16a34a;
}

/* ── Composite provenance (real annotation engine) ────────────────────────
   Naming matches annotate.js's compositeKey()/cssClassFor() output. */
.ann-paste {
  background-color: #fef9c3;
  border-bottom: 2px solid #ca8a04;
}
.ann-ai {
  background-color: #ede9ff;
  border-bottom: 2px solid #7c3aed;
}
.ann-ai-partial {
  background-color: #ccfbf1;
  border-bottom: 2px solid #0d9488;
}
.ann-ai-then-edited {
  background-color: #dbeafe;
  border-bottom: 2px solid #3b82f6;
}
.ann-paste-then-ai {
  background-color: #fde7f3;
  border-bottom: 2px solid #c026d3;
}
.ann-human-then-ai {
  background-color: #dbeafe;
  border-bottom: 2px solid #3b82f6;
}
/* Fallback for longer/uncommon provenance chains not covered above —
   driven by inline custom properties rather than one class per chain. */
.ann-composite {
  background-color: #e5e7eb;
  border-bottom: 2px solid #6b7280;
}

/* ── Annotation tooltip ────────────────────────────────────────────────── */
.ann-tip {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #f9fafb;
  font-family: system-ui, sans-serif;
  font-size: 0.72rem;
  line-height: 1.4;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 10;
  pointer-events: none;
}

.ann-tip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #111827;
}

.ann:hover .ann-tip {
  display: block;
}

/* ── Sidebar ───────────────────────────────────────────────────────────── */
.viewer-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.viewer-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  font-family: system-ui, sans-serif;
}

.viewer-card h3 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
  margin-bottom: 0.875rem;
}

/* ── Stats ─────────────────────────────────────────────────────────────── */
.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0;
  font-size: 0.825rem;
}

.stat-row .label {
  color: #6b7280;
}

.stat-row .value {
  font-weight: 600;
  color: #111827;
}

/* ── Legend ────────────────────────────────────────────────────────────── */
.legend-item {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 0.8rem;
}

.legend-item:last-child {
  border-bottom: none;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
  margin-top: 2px;
}

.legend-swatch.human   { background: #f3f4f6; border: 1px solid #d1d5db; }
.legend-swatch.revised { background: #dbeafe; border-bottom: 2px solid #3b82f6; }
.legend-swatch.unmod   { background: #fef9c3; border-bottom: 2px solid #f59e0b; }
.legend-swatch.source  { background: #dcfce7; border-bottom: 2px solid #16a34a; }

/* Legend swatches for the real annotation engine — reuses the .ann-* classes
   directly so colors never drift out of sync with the document highlights. */
.legend-swatch.ann-paste,
.legend-swatch.ann-ai,
.legend-swatch.ann-ai-partial,
.legend-swatch.ann-ai-then-edited,
.legend-swatch.ann-paste-then-ai,
.legend-swatch.ann-human-then-ai,
.legend-swatch.ann-composite {
  border: none;
}

.legend-text .type {
  font-weight: 600;
  color: #374151;
}

.legend-text .desc {
  color: #9ca3af;
  font-size: 0.72rem;
  margin-top: 1px;
}

/* ── EU label icon container ───────────────────────────────────────────── */
.eu-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-family: system-ui, sans-serif;
  font-size: 0.72rem;
  color: #475569;
}

.eu-label svg {
  flex-shrink: 0;
}

/* ── Drop zone (public /viewer page) ──────────────────────────────────── */
#drop-zone.drag-over {
  border-color: #2bb673;
  background: #f0fdf4;
}

/* ── No-file state ─────────────────────────────────────────────────────── */
.viewer-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  color: #9ca3af;
  font-family: system-ui, sans-serif;
}

.viewer-empty svg {
  color: #d1d5db;
  margin-bottom: 1rem;
}

.viewer-empty p {
  font-size: 0.875rem;
}

.viewer-empty .sub {
  font-size: 0.75rem;
  margin-top: 0.25rem;
}
