/* assets/styles.css */
/* Layout */
:root {
  --bg-body: #f4f5f7;
  --bg-surface: #ffffff;
  --border-subtle: #e2e4ea;
  --text-main: #111827;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #e0edff;
  --danger: #b91c1c;
  --radius-lg: 0;
  --radius-pill: 0;
  --shadow-soft: 0 1px 3px rgba(15, 23, 42, 0.06);
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;

  /* Highlight palette (underline colors) - now using color names */
  --hl-purple: rgba(192, 132, 252, 0.95);
  --hl-green: rgba(134, 239, 172, 0.95);
  --hl-pink: rgba(253, 164, 175, 0.95);
  --hl-yellow: rgba(250, 204, 21, 0.95);
  --hl-blue: rgba(147, 197, 253, 0.95);
  --hl-orange: rgba(251, 146, 60, 0.95);
  --hl-red: rgba(248, 113, 113, 0.95);
  --hl-pending: rgba(59, 130, 246, 0.55);
  --hl-local: rgba(239, 68, 68, 0.45);

  /* Legacy aliases for backward compatibility */
  --hl-useful: var(--hl-green);
  --hl-love: var(--hl-pink);
  --hl-thought: var(--hl-yellow);
  --hl-slow: var(--hl-blue);
  --hl-confusing: var(--hl-purple);

  /* Highlight fill (background) — same hues as underline, softer alpha */
  --hlbg-purple: rgba(192, 132, 252, 0.28);
  --hlbg-green: rgba(134, 239, 172, 0.28);
  --hlbg-pink: rgba(253, 164, 175, 0.28);
  --hlbg-yellow: rgba(250, 204, 21, 0.28);
  --hlbg-blue: rgba(147, 197, 253, 0.26);
  --hlbg-orange: rgba(251, 146, 60, 0.26);
  --hlbg-red: rgba(248, 113, 113, 0.26);
  --hlbg-pending: rgba(59, 130, 246, 0.14);
  --hlbg-local: rgba(239, 68, 68, 0.12);

  /* Legacy aliases */
  --hlbg-useful: var(--hlbg-green);
  --hlbg-love: var(--hlbg-pink);
  --hlbg-thought: var(--hlbg-yellow);
  --hlbg-slow: var(--hlbg-blue);
  --hlbg-confusing: var(--hlbg-purple);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body.app-shell {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at top, #f9fafb 0, #e5e7eb 45%, #d1d5db 100%);
  font-family: var(--font-sans);
  color: var(--text-main);
}

/* ---------- Viewer (reader-facing) minimal layout ---------- */

body.app-shell.viewer-shell {
  background: #ffffff;
}

.viewer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  position: sticky;
  top: 0;
  z-index: 80;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

.viewer-top-left {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.viewer-select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 2px;
  padding: 8px 10px;
  font-size: 13px;
  background: #ffffff;
  max-width: 44vw;
}

.viewer-filter {
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 2px;
  padding: 8px 10px;
  font-size: 13px;
  background: #ffffff;
  color: #111827;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  touch-action: manipulation;
}

.viewer-filter-icon {
  font-size: 16px;
  line-height: 1;
}

.viewer-filter-label {
  line-height: 1;
}

.viewer-filter:hover {
  background: rgba(148, 163, 184, 0.10);
}

.viewer-filter[aria-pressed="true"] {
  background: rgba(17, 24, 39, 0.06);
  border-color: rgba(17, 24, 39, 0.25);
}

.viewer-admin-link {
  font-size: 13px;
  color: #111827;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 2px;
  border: 1px solid rgba(148, 163, 184, 0.45);
}

.viewer-admin-link:hover {
  background: rgba(148, 163, 184, 0.10);
}

.viewer-main {
  padding: 0;
}

.doc-surface.viewer-surface {
  max-width: 760px;
  padding: 26px 18px 34px;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}

.viewer-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.viewer-title {
  margin: 0;
}

.viewer-title.loading-title {
  font-size: 22px;
  font-weight: 700;
}

@media (max-width: 520px) {
  .viewer-title.loading-title {
    font-size: 18px;
  }
}

.loading-dots {
  display: inline-flex;
  gap: 2px;
  margin-left: 4px;
  vertical-align: baseline;
}

.loading-dots span {
  opacity: 0.2;
  animation: loadingDot 1.2s infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes loadingDot {
  0%, 20% { opacity: 0.2; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-1px); }
  80%, 100% { opacity: 0.2; transform: translateY(0); }
}


.viewer-meta {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

body.viewer-embed .viewer-top-right {
  display: none;
}

/* Non-persistent selection highlight (when a reader drags to select text).
   Keep it yellow instead of the system blue. */
.viewer-shell ::selection {
  background: rgba(250, 204, 21, 0.42);
  color: inherit;
}
.viewer-shell ::-moz-selection {
  background: rgba(250, 204, 21, 0.42);
  color: inherit;
}

@media (max-width: 760px) {
  .viewer-top {
    padding: 10px 12px;
  }
  /* Prevent overlap on small screens (the admin link can otherwise sit atop the filter). */
  .viewer-top {
    flex-wrap: wrap;
    gap: 10px;
  }
  .viewer-top-left,
  .viewer-top-right {
    width: 100%;
  }
  .viewer-top-right {
    display: flex;
    justify-content: flex-end;
  }
  .viewer-select {
    padding: 7px 9px;
    max-width: 46vw;
  }
  /* Make the filter compact on mobile: icon-only */
  .viewer-filter {
    padding: 7px;
    width: 38px;
    justify-content: center;
  }
  .viewer-filter-label {
    display: none;
  }
  .doc-surface.viewer-surface {
    padding: 20px 14px 28px;
  }
  .doc-title.viewer-title {
    font-size: 24px;
  }
  .doc-body p {
    font-size: 16px;
  }
  /* Reserve a right gutter for comment markers so text never shifts */
  .viewer-shell .doc-body .doc-block,
  .af-article-body .doc-block {
    padding-right: 44px;
  }
  /* Hide marker bubbles on mobile — readers tap highlighted text directly */
  .viewer-shell .hl-marker,
  .af-article-body .hl-marker {
    display: none;
  }
  .viewer-shell .doc-body .doc-block,
  .af-article-body .doc-block,
  .af-article-body > p,
  .af-article-body > h1,
  .af-article-body > h2,
  .af-article-body > h3,
  .af-article-body > h4,
  .af-article-body > h5,
  .af-article-body > h6,
  .af-article-body > ul,
  .af-article-body > ol,
  .af-article-body > blockquote,
  .af-article-body > div {
    padding-right: 0;
  }
}


/* Top bar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.3);
  backdrop-filter: blur(18px);
  background: linear-gradient(
    to bottom,
    rgba(248, 250, 252, 0.9),
    rgba(241, 245, 249, 0.85)
  );
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-left {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-dot {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: radial-gradient(circle at 30% 20%, #22c55e, #0f766e);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2);
}

.brand-title {
  font-weight: 600;
  letter-spacing: 0.03em;
  font-size: 14px;
  text-transform: uppercase;
  color: #111827;
}

.topbar-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Buttons & chips */

.pill-button {
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  border: 1px solid transparent;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #f9fafb;
  color: #111827;
}

.pill-button:hover {
  background: #e5e7eb;
}

.pill-primary {
  background: #111827;
  color: #f9fafb;
  border-color: #111827;
}

.pill-primary:hover {
  background: #020617;
}

.pill-ghost {
  background: transparent;
  border-color: rgba(148, 163, 184, 0.6);
  color: #111827;
}

.pill-ghost:hover {
  background: rgba(148, 163, 184, 0.12);
}

.pill-danger {
  background: rgba(248, 113, 113, 0.12);
  color: #b91c1c;
  border-color: rgba(248, 113, 113, 0.7);
}

.status-chip {
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  font-size: 11px;
  border: 1px solid transparent;
}

.status-chip-pending {
  background: #fef9c3;
  border-color: #facc15;
  color: #854d0e;
}

.status-chip-ok {
  background: #dcfce7;
  border-color: #22c55e;
  color: #166534;
}

.status-chip-error {
  background: #fee2e2;
  border-color: #ef4444;
  color: #b91c1c;
}

/* Main layout */

.main-layout {
  display: grid;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  gap: 24px;
  padding: 24px 32px 40px;
}

.panel {
  border-radius: var(--radius-lg);
  background: rgba(248, 250, 252, 0.95);
  box-shadow: var(--shadow-soft);
  padding: 20px 22px;
}

.panel-sidebar {
  max-height: calc(100vh - 120px);
  overflow: auto;
}

.panel-article {
  padding: 0;
  background: transparent;
  box-shadow: none;
}

/* Article doc surface */

.doc-surface {
  margin: 0 auto;
  max-width: 760px;
  padding: 40px 52px 48px;
  background: var(--bg-surface);
  border-radius: 0;
  box-shadow: var(--shadow-soft);
}

.doc-title {
  margin: 0 0 4px;
  font-size: 30px;
  letter-spacing: 0.02em;
}

.doc-meta {
  margin-bottom: 22px;
  font-size: 13px;
  color: var(--text-muted);
}

.doc-body p {
  margin: 0 0 16px;
  line-height: 1.7;
  font-size: 16px;
}

/* Cards */

.card {
  margin: 10px auto;
  max-width: 900px;
  background: var(--bg-surface);
  border-radius: 0;
  box-shadow: var(--shadow-soft);
  padding: 14px 16px 12px;
}

.card-header-row,
.card-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  margin: 0;
  font-size: 20px;
}

.card-subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.card-body {
  margin-top: 18px;
}

/* Article select row with action buttons */
.article-select-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.article-select-row .field-select {
  flex: 1;
}

.article-select-row .pill-button {
  padding: 6px 10px;
  min-width: auto;
  height: 36px;
}

/* Form controls */

.field-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.2fr);
  gap: 14px 16px;
  margin-bottom: 12px;
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #6b7280;
  margin-bottom: 4px;
}

.field-input,
.field-select,
.doc-editor {
  width: 100%;
  border-radius: 2px;
  border: 1px solid var(--border-subtle);
  padding: 8px 10px;
  font-size: 14px;
  font-family: var(--font-sans);
  background: #f9fafb;
}

.field-input:focus,
.field-select:focus,
.doc-editor:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
  background: #ffffff;
}

.field-select-compact {
  padding-top: 4px;
  padding-bottom: 4px;
}

/* Editor */

.doc-editor {
  min-height: 260px;
  resize: vertical;
  margin-top: 6px;
  white-space: pre-wrap;
}

/* Toolbar */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.toolbar-group {
  display: inline-flex;
  gap: 4px;
  padding: 2px;
  border-radius: 2px;
  background: #e5e7eb;
}

.toolbar-btn {
  min-width: 32px;
  border-radius: 2px;
  border: none;
  padding: 4px 10px;
  font-size: 12px;
  background: #f9fafb;
  cursor: pointer;
}

.toolbar-btn:hover {
  background: #e5e7eb;
}

/* Helper text */

.helper-text {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Moderation */

.moderation-empty {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.moderation-controls {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  user-select: none;
}

.inline-check input {
  width: 16px;
  height: 16px;
}

.pill-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Versions list (admin) */

.version-list {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.version-item {
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 0;
  background: rgba(248, 250, 252, 0.7);
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.version-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.version-title {
  font-size: 13px;
  font-weight: 650;
}

.version-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.version-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ---------- Rich text rendering (viewer + admin preview) ---------- */

.doc-body h1,
.doc-body h2,
.doc-body h3 {
  margin: 18px 0 10px;
  line-height: 1.25;
}

.doc-body h1 { font-size: 28px; }
.doc-body h2 { font-size: 22px; }
.doc-body h3 { font-size: 18px; }

.doc-body ul,
.doc-body ol {
  margin: 0 0 16px 22px;
  padding: 0;
  line-height: 1.7;
  font-size: 16px;
}

.doc-body li { margin: 0 0 6px; }

.doc-body img.doc-img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 14px 0 18px;
  border-radius: 0;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

/* ---------- Contenteditable editor ---------- */

.doc-editor-rich {
  white-space: normal;
  min-height: 280px;
  padding: 12px 12px;
  background: #ffffff;
}

.doc-editor-rich:empty::before {
  content: 'Write here…';
  color: #94a3b8;
}

.doc-editor-rich p { margin: 0 0 16px; line-height: 1.7; }
.doc-editor-rich h1 { margin: 18px 0 10px; font-size: 28px; }
.doc-editor-rich h2 { margin: 18px 0 10px; font-size: 22px; }
.doc-editor-rich h3 { margin: 14px 0 8px; font-size: 18px; }
.doc-editor-rich ul,
.doc-editor-rich ol { margin: 0 0 16px 22px; line-height: 1.7; }
.doc-editor-rich img { max-width: 100%; height: auto; border-radius: 0; }

/* ---------- Preview panel ---------- */

.preview-panel {
  margin-top: 14px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 0;
  background: rgba(248, 250, 252, 0.75);
  padding: 12px 14px;
}

.preview-panel.hidden { display: none; }

.preview-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.preview-note {
  font-size: 12px;
  color: var(--text-muted);
}

.preview-body .doc-block { margin-bottom: 0; }

.preview-body p { margin: 0 0 16px; line-height: 1.7; font-size: 16px; }
.preview-body h1 { margin: 18px 0 10px; line-height: 1.25; font-size: 28px; }
.preview-body h2 { margin: 18px 0 10px; line-height: 1.25; font-size: 22px; }
.preview-body h3 { margin: 14px 0 8px; line-height: 1.25; font-size: 18px; }
.preview-body ul,
.preview-body ol { margin: 0 0 16px 22px; line-height: 1.7; font-size: 16px; }
.preview-body li { margin: 0 0 6px; }
.preview-body img { display: block; max-width: 100%; height: auto; margin: 14px 0 18px; border-radius: 0; border: 1px solid rgba(148, 163, 184, 0.35); }

/* ---------- Highlights ---------- */

/*
  Meaning palette (reactions)
  - Useful!     = helpful, practical value
  - Love this   = emotional resonance / delight
  - Thought     = interesting / reflective
  - Feels slow  = pacing issue
  - Confusing   = clarity issue
*/

mark.hl {
  background: var(--hlbg-thought);
  /* No padding to avoid changing line breaks / wrapping when highlights are rendered. */
  padding: 0;
  margin: 0;
  border: 0;
  display: inline;
  line-height: inherit;
  /* Hard edges (traditional highlighter look). Keep 0 padding to avoid reflow. */
  border-radius: 0;
  color: inherit;
  box-decoration-break: clone;
  /* Default: single 1px underline. Multi-underline is applied inline via JS. */
  box-shadow: inset 0 -1px 0 var(--hl-thought);
}

/* Yellow OS selection highlight (non-persistent) for the viewer */
.viewer-shell ::selection {
  background: rgba(250, 204, 21, 0.38);
  color: inherit;
}

.viewer-shell ::-moz-selection {
  background: rgba(250, 204, 21, 0.38);
  color: inherit;
}

/* Fill uses the same hue as the underline (dominant meaning), but with softer alpha. */
/* Color-based classes */
mark.hl.hl-purple { background: var(--hlbg-purple); box-shadow: inset 0 -1px 0 var(--hl-purple); }
mark.hl.hl-green { background: var(--hlbg-green); box-shadow: inset 0 -1px 0 var(--hl-green); }
mark.hl.hl-pink { background: var(--hlbg-pink); box-shadow: inset 0 -1px 0 var(--hl-pink); }
mark.hl.hl-yellow { background: var(--hlbg-yellow); box-shadow: inset 0 -1px 0 var(--hl-yellow); }
mark.hl.hl-blue { background: var(--hlbg-blue); box-shadow: inset 0 -1px 0 var(--hl-blue); }
mark.hl.hl-orange { background: var(--hlbg-orange); box-shadow: inset 0 -1px 0 var(--hl-orange); }
mark.hl.hl-red { background: var(--hlbg-red); box-shadow: inset 0 -1px 0 var(--hl-red); }

/* Legacy classes for backward compatibility */
mark.hl.hl-useful { background: var(--hlbg-green); box-shadow: inset 0 -1px 0 var(--hl-green); }
mark.hl.hl-love { background: var(--hlbg-pink); box-shadow: inset 0 -1px 0 var(--hl-pink); }
mark.hl.hl-thought { background: var(--hlbg-yellow); box-shadow: inset 0 -1px 0 var(--hl-yellow); }
mark.hl.hl-slow { background: var(--hlbg-blue); box-shadow: inset 0 -1px 0 var(--hl-blue); }
mark.hl.hl-confusing { background: var(--hlbg-purple); box-shadow: inset 0 -1px 0 var(--hl-purple); }

mark.hl.hl-pending { background: var(--hlbg-pending); box-shadow: inset 0 -1px 0 var(--hl-pending); }
mark.hl.hl-local { background: var(--hlbg-local); box-shadow: inset 0 -1px 0 var(--hl-local); }

/* Suppress mobile copy/paste/search action bar on article content */
.af-article-body,
.af-article-body * {
  -webkit-touch-callout: none !important;
  -webkit-user-modify: read-only !important;
}
.af-article-body {
  -webkit-user-select: text;
  user-select: text;
}

/* Reserve a right gutter for comment markers so text never shifts when
   highlights/comments appear live. Works for both shortcode and auto-inject. */
.viewer-shell .doc-body .doc-block,
/* Pre-reserve right gutter on article body children to prevent shift when JS wraps them */
.af-article-body > p,
.af-article-body > h1,
.af-article-body > h2,
.af-article-body > h3,
.af-article-body > h4,
.af-article-body > h5,
.af-article-body > h6,
.af-article-body > ul,
.af-article-body > ol,
.af-article-body > blockquote,
.af-article-body > div:not(.af-info-btn):not(.af-pull-quote):not(.af-branded-footer) {
  padding-right: 56px;
}

.af-article-body .doc-block {
  position: relative;
  padding-right: 56px;
}

/* Kept for backward compatibility (JS adds this class), but styling lives above. */
.doc-block-hl {
  position: relative;
}

.hl-marker {
  position: absolute;
  right: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: transparent;
  color: #0f172a;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 0;
}

.hl-marker:hover {
  background: rgba(15, 23, 42, 0.04);
}

.hl-marker-icon {
  font-size: 16px;
  line-height: 1;
}

.hl-marker-count {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1;
}

/* Marker icon colors - color-based */
.hl-marker-purple .hl-marker-icon { color: rgba(147, 51, 234, 0.9); }
.hl-marker-green .hl-marker-icon { color: rgba(22, 163, 74, 0.9); }
.hl-marker-pink .hl-marker-icon { color: rgba(225, 29, 72, 0.85); }
.hl-marker-yellow .hl-marker-icon { color: rgba(161, 98, 7, 0.9); }
.hl-marker-blue .hl-marker-icon { color: rgba(2, 132, 199, 0.9); }
.hl-marker-orange .hl-marker-icon { color: rgba(234, 88, 12, 0.9); }
.hl-marker-red .hl-marker-icon { color: rgba(220, 38, 38, 0.9); }

/* Legacy marker colors */
.hl-marker-useful .hl-marker-icon { color: rgba(22, 163, 74, 0.9); }
.hl-marker-love .hl-marker-icon { color: rgba(225, 29, 72, 0.85); }
.hl-marker-thought .hl-marker-icon { color: rgba(161, 98, 7, 0.9); }
.hl-marker-slow .hl-marker-icon { color: rgba(2, 132, 199, 0.9); }
.hl-marker-confusing .hl-marker-icon { color: rgba(126, 34, 206, 0.9); }

/* ---------- Selection / comment UI ---------- */

.comment-bubble {
  position: absolute;
  width: 200px;
  max-width: calc(100vw - 16px);
  z-index: 50;
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.5);
  border-radius: 2px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  padding: 8px 8px 6px;
}

.selection-popover {
  position: absolute;
  width: 200px;
  max-width: calc(100vw - 16px);
  z-index: 50;
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.5);
  border-radius: 2px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  overflow: hidden;
}

.selection-popover .hl-popover-view {
  padding: 8px 8px 6px;
  box-sizing: border-box;
  align-self: flex-start;
}

.selection-popover.hidden,
.comment-bubble.hidden {
  display: none;
}

.selection-popover-row,
.comment-bubble-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  font-size: 12px;
}

.popover-close {
  border: none;
  background: transparent;
  font-size: 15px;
  cursor: pointer;
  line-height: 1;
  color: #64748b;
}

.popover-textarea {
  width: 100%;
  border-radius: 2px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  padding: 5px 7px;
  font-family: var(--font-sans);
  font-size: 12px;
  resize: vertical;
  -webkit-appearance: none;
  box-sizing: border-box;
}

.selection-popover-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 6px;
}

.selection-popover-actions .pill-button {
  height: 28px;
  min-width: 28px;
  padding: 0 8px;
  font-size: 12px;
}

.popover-hint {
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-muted);
}

/* Compact pill inside selection popover */
.selection-popover .reaction-pill {
  font-size: 11px;
  padding: 4px 8px;
  gap: 5px;
  border-radius: 2px;
}

.selection-popover .popover-textarea {
  font-size: 12px;
}

.reaction-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 3px;
  margin-top: 4px;
}

.reaction-choice {
  width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: #fff;
  padding: 5px 7px;
  border-radius: 2px;
  cursor: pointer;
  text-align: left;
}

.reaction-choice:hover {
  background: rgba(15, 23, 42, 0.03);
}

.reaction-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  font-size: 11px;
  line-height: 1;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(248, 250, 252, 0.9);
}

.reaction-label {
  font-size: 11px;
  color: #0f172a;
}

/* Non-blocking toast (replaces alert dialogs) */
.toast {
  position: fixed;
  right: 14px;
  bottom: 14px;
  max-width: 320px;
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.35;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  z-index: 9999;
}

.toast-hidden {
  display: none;
}

.toast-warn {
  border-color: rgba(245, 158, 11, 0.55);
}

.toast-error {
  border-color: rgba(239, 68, 68, 0.55);
}

/* Cognitive ease: picker options carry the same hue as their highlight. */
/* Color-based classes */
.reaction-choice.reaction-purple {
  background: var(--hlbg-purple);
  border-color: rgba(147, 51, 234, 0.35);
}
.reaction-choice.reaction-green {
  background: var(--hlbg-green);
  border-color: rgba(22, 163, 74, 0.35);
}
.reaction-choice.reaction-pink {
  background: var(--hlbg-pink);
  border-color: rgba(225, 29, 72, 0.28);
}
.reaction-choice.reaction-yellow {
  background: var(--hlbg-yellow);
  border-color: rgba(161, 98, 7, 0.28);
}
.reaction-choice.reaction-blue {
  background: var(--hlbg-blue);
  border-color: rgba(2, 132, 199, 0.25);
}
.reaction-choice.reaction-orange {
  background: var(--hlbg-orange);
  border-color: rgba(234, 88, 12, 0.30);
}
.reaction-choice.reaction-red {
  background: var(--hlbg-red);
  border-color: rgba(220, 38, 38, 0.30);
}

/* Color-based icon backgrounds */
.reaction-choice.reaction-purple .reaction-icon {
  background: rgba(192, 132, 252, 0.30);
  border-color: rgba(147, 51, 234, 0.25);
}
.reaction-choice.reaction-green .reaction-icon {
  background: rgba(134, 239, 172, 0.30);
  border-color: rgba(22, 163, 74, 0.25);
}
.reaction-choice.reaction-pink .reaction-icon {
  background: rgba(253, 164, 175, 0.26);
  border-color: rgba(225, 29, 72, 0.20);
}
.reaction-choice.reaction-yellow .reaction-icon {
  background: rgba(250, 204, 21, 0.22);
  border-color: rgba(161, 98, 7, 0.20);
}
.reaction-choice.reaction-blue .reaction-icon {
  background: rgba(147, 197, 253, 0.24);
  border-color: rgba(2, 132, 199, 0.18);
}
.reaction-choice.reaction-orange .reaction-icon {
  background: rgba(251, 146, 60, 0.26);
  border-color: rgba(234, 88, 12, 0.20);
}
.reaction-choice.reaction-red .reaction-icon {
  background: rgba(248, 113, 113, 0.26);
  border-color: rgba(220, 38, 38, 0.20);
}

/* Legacy classes for backward compatibility */
.reaction-choice.reaction-useful {
  background: var(--hlbg-green);
  border-color: rgba(22, 163, 74, 0.35);
}
.reaction-choice.reaction-love {
  background: var(--hlbg-pink);
  border-color: rgba(225, 29, 72, 0.28);
}
.reaction-choice.reaction-thought {
  background: var(--hlbg-yellow);
  border-color: rgba(161, 98, 7, 0.28);
}
.reaction-choice.reaction-slow {
  background: var(--hlbg-blue);
  border-color: rgba(2, 132, 199, 0.25);
}
.reaction-choice.reaction-confusing {
  background: var(--hlbg-purple);
  border-color: rgba(126, 34, 206, 0.25);
}

.reaction-choice.reaction-useful .reaction-icon {
  background: rgba(134, 239, 172, 0.30);
  border-color: rgba(22, 163, 74, 0.25);
}
.reaction-choice.reaction-love .reaction-icon {
  background: rgba(253, 164, 175, 0.26);
  border-color: rgba(225, 29, 72, 0.20);
}
.reaction-choice.reaction-thought .reaction-icon {
  background: rgba(250, 204, 21, 0.22);
  border-color: rgba(161, 98, 7, 0.20);
}
.reaction-choice.reaction-slow .reaction-icon {
  background: rgba(147, 197, 253, 0.24);
  border-color: rgba(2, 132, 199, 0.18);
}
.reaction-choice.reaction-confusing .reaction-icon {
  background: rgba(216, 180, 254, 0.26);
  border-color: rgba(126, 34, 206, 0.18);
}

.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 2px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(248, 250, 252, 0.9);
  color: #0f172a;
}

/* Color-based reaction pill styles */
.reaction-pill.reaction-purple { background: rgba(192, 132, 252, 0.35); }
.reaction-pill.reaction-green { background: rgba(134, 239, 172, 0.35); }
.reaction-pill.reaction-pink { background: rgba(253, 164, 175, 0.30); }
.reaction-pill.reaction-yellow { background: rgba(250, 204, 21, 0.28); }
.reaction-pill.reaction-blue { background: rgba(147, 197, 253, 0.32); }
.reaction-pill.reaction-orange { background: rgba(251, 146, 60, 0.32); }
.reaction-pill.reaction-red { background: rgba(248, 113, 113, 0.32); }

/* Legacy pill colors */
.reaction-pill.reaction-useful { background: rgba(134, 239, 172, 0.35); }
.reaction-pill.reaction-love { background: rgba(253, 164, 175, 0.30); }
.reaction-pill.reaction-thought { background: rgba(250, 204, 21, 0.28); }
.reaction-pill.reaction-slow { background: rgba(147, 197, 253, 0.32); }
.reaction-pill.reaction-confusing { background: rgba(216, 180, 254, 0.35); }

.pill-button {
  height: 34px;
  min-width: 34px;
  padding: 0 12px;
  border-radius: 2px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.pill-button.pill-primary {
  background: #0f172a;
  border-color: #0f172a;
  color: #fff;
}

.pill-button.pill-ghost {
  background: rgba(248, 250, 252, 0.9);
}

.send-icon {
  font-size: 14px;
  line-height: 1;
}

/* ---------- Thread popover ---------- */

.thread-popover {
  position: absolute;
  width: 360px;
  max-width: calc(100vw - 16px);
  z-index: 60;
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.5);
  border-radius: 0;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
  padding: 10px;
}

.thread-popover.hidden { display: none; }

.thread-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.thread-nav {
  height: 30px;
  width: 30px;
  border-radius: 2px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: #fff;
  cursor: pointer;
  color: #0f172a;
}

.thread-nav:disabled {
  opacity: 0.45;
  cursor: default;
}

.thread-page {
  flex: 1;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

.thread-body {
  padding: 2px;
}

.thread-card {
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 0;
  background: rgba(248, 250, 252, 0.7);
  padding: 12px;
}

.thread-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.thread-edit {
  margin-left: auto;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: #fff;
  border-radius: 2px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  color: #0f172a;
}

.thread-edit:hover {
  background: rgba(148, 163, 184, 0.10);
}

.thread-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.thread-actions .thread-edit {
  margin-left: 0;
}

.thread-delete {
  border: 1px solid rgba(244, 63, 94, 0.45);
  background: #fff;
  border-radius: 2px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  color: #b91c1c;
}

.thread-delete:hover {
  background: rgba(244, 63, 94, 0.08);
}


.thread-avatar {
  width: 34px;
  height: 34px;
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #0f172a;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
}

.thread-name {
  font-size: 13px;
  font-weight: 700;
}

.thread-when {
  font-size: 12px;
  color: var(--text-muted);
}

.thread-pill-row {
  margin-bottom: 10px;
}

.thread-text {
  font-size: 14px;
  line-height: 1.6;
}

.avg-header {
  margin-bottom: 10px;
}

.avg-title {
  font-weight: 800;
  font-size: 14px;
}

.avg-sub {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.avg-list {
  display: grid;
  gap: 8px;
}

.avg-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.avg-count {
  font-size: 12px;
  color: var(--text-muted);
}

.avg-foot {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.comment-bubble-text {
  font-size: 13px;
  line-height: 1.6;
  color: #0f172a;
}

/* ---------- Moderation list ---------- */

.moderation-list {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.moderation-item {
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 0;
  background: rgba(248, 250, 252, 0.7);
  padding: 12px 12px 10px;
}

.moderation-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.moderation-quote {
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 6px;
  padding-left: 10px;
  border-left: 3px solid rgba(148, 163, 184, 0.55);
}

/* Admin moderation: show the same meaning color as the highlight. */
/* Color-based classes */
.moderation-quote.hl-purple { border-left-color: var(--hl-purple); }
.moderation-quote.hl-green { border-left-color: var(--hl-green); }
.moderation-quote.hl-pink { border-left-color: var(--hl-pink); }
.moderation-quote.hl-yellow { border-left-color: var(--hl-yellow); }
.moderation-quote.hl-blue { border-left-color: var(--hl-blue); }
.moderation-quote.hl-orange { border-left-color: var(--hl-orange); }
.moderation-quote.hl-red { border-left-color: var(--hl-red); }

/* Legacy classes */
.moderation-quote.hl-useful { border-left-color: var(--hl-green); }
.moderation-quote.hl-love { border-left-color: var(--hl-pink); }
.moderation-quote.hl-thought { border-left-color: var(--hl-yellow); }
.moderation-quote.hl-slow { border-left-color: var(--hl-blue); }
.moderation-quote.hl-confusing { border-left-color: var(--hl-purple); }
.moderation-quote.hl-pending { border-left-color: var(--hl-pending); }

.moderation-comment {
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 10px;
}

.moderation-actions {
  display: flex;
  justify-content: flex-end;
}

/* ----------------------------------------------------
   Admin: mobile-first layout tweaks
   ---------------------------------------------------- */

.admin-shell .main-layout {
  grid-template-columns: 1fr;
  padding: 18px 16px 28px;
}

.admin-shell .topbar {
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 14px;
}

.admin-shell .topbar-right {
  flex-wrap: wrap;
  gap: 8px;
}

.moderation-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.moderation-filters {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1.4fr;
  gap: 10px;
}

.moderation-actions-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 820px) {
  .admin-shell .main-layout {
    padding: 12px 12px 22px;
  }

  .admin-shell .card {
    margin: 6px auto;
    padding: 10px 10px;
  }

  .admin-shell .topbar-right {
    width: 100%;
    justify-content: flex-start;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .moderation-filters {
    grid-template-columns: 1fr;
  }
}

/* ----------------------------------------------------
   Reaction Template Panel (inline, above moderation)
   ---------------------------------------------------- */

.template-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.template-reactions-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.ref-reaction {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 2px;
  border-left: 3px solid transparent;
  white-space: nowrap;
}

.ref-icon {
  font-size: 14px;
}

/* Reference panel colors */
.ref-reaction.ref-purple {
  background: var(--hlbg-purple);
  border-left-color: var(--hl-purple);
}
.ref-reaction.ref-green {
  background: var(--hlbg-green);
  border-left-color: var(--hl-green);
}
.ref-reaction.ref-pink {
  background: var(--hlbg-pink);
  border-left-color: var(--hl-pink);
}
.ref-reaction.ref-yellow {
  background: var(--hlbg-yellow);
  border-left-color: var(--hl-yellow);
}
.ref-reaction.ref-blue {
  background: var(--hlbg-blue);
  border-left-color: var(--hl-blue);
}
.ref-reaction.ref-orange {
  background: var(--hlbg-orange);
  border-left-color: var(--hl-orange);
}
.ref-reaction.ref-red {
  background: var(--hlbg-red);
  border-left-color: var(--hl-red);
}

@media (max-width: 500px) {
  .template-panel-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .template-panel-header .field {
    width: 100%;
  }
}

/* ----------------------------------------------------
   Article Stats Panel
   ---------------------------------------------------- */

.stats-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.stats-summary {
  display: flex;
  gap: 12px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 10px;
  background: rgba(148, 163, 184, 0.06);
  border-radius: 2px;
}

.stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.stat-label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.reaction-breakdown {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.reaction-bar-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.reaction-bar-label {
  min-width: 90px;
  font-size: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.reaction-bar-icon {
  font-size: 11px;
}

.reaction-bar-track {
  flex: 1;
  height: 10px;
  background: rgba(148, 163, 184, 0.10);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.reaction-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
}

.reaction-bar-fill.bar-purple { background: var(--hl-purple); }
.reaction-bar-fill.bar-green { background: var(--hl-green); }
.reaction-bar-fill.bar-pink { background: var(--hl-pink); }
.reaction-bar-fill.bar-yellow { background: var(--hl-yellow); }
.reaction-bar-fill.bar-blue { background: var(--hl-blue); }
.reaction-bar-fill.bar-orange { background: var(--hl-orange); }
.reaction-bar-fill.bar-red { background: var(--hl-red); }

.reaction-bar-value {
  min-width: 40px;
  font-size: 10px;
  font-weight: 600;
  text-align: right;
  color: var(--text-main);
}

.reaction-bar-count {
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 2px;
}

@media (max-width: 500px) {
  .stats-panel-header {
    flex-direction: column;
  }
  
  .stats-summary {
    width: 100%;
    justify-content: space-around;
  }
  
  .reaction-bar-label {
    min-width: 70px;
  }
}

/* ----------------------------------------------------
   Modal Overlay (Reader Info, etc.)
   ---------------------------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 9999;
  padding: 48px 16px 16px;
  overflow-y: auto;
}

.modal-content {
  background: #fff;
  border-radius: 0;
  padding: 16px 18px;
  max-width: 320px;
  width: 100%;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

.modal-title {
  display: none;
}

.modal-subtitle {
  display: none;
}

.modal-field {
  margin-bottom: 12px;
}

.modal-field .field-label {
  display: block;
  margin-bottom: 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.modal-field .field-input,
.modal-field .field-select {
  width: 100%;
  box-sizing: border-box;
  font-size: 13px;
  padding: 8px 10px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

/* ----------------------------------------------------
   Article Settings Toggles
   ---------------------------------------------------- */

.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.toggle-setting {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(148, 163, 184, 0.06);
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.15s;
}

.toggle-setting:hover {
  background: rgba(148, 163, 184, 0.12);
}

.toggle-setting input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--hl-green);
  cursor: pointer;
}

.toggle-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toggle-label strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.toggle-desc {
  font-size: 12px;
  color: var(--text-muted);
}

/* ----------------------------------------------------
   Share & Embed Section
   ---------------------------------------------------- */

.share-options {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 16px;
}

.copy-field {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.copy-field .field-input {
  flex: 1;
  font-size: 12px;
  font-family: 'SF Mono', Monaco, monospace;
}

.embed-textarea {
  resize: vertical;
  min-height: 80px;
}

.copy-btn {
  flex-shrink: 0;
}

/* ── WordPress Admin Overrides ── */

.af-admin-wrap .app-shell {
  margin: 0;
  padding: 0;
  background: #f8fafc;
  font-family: var(--font-sans);
}

.af-admin-wrap .main-layout {
  padding: 6px 0;
}

.af-admin-wrap .card {
  margin: 10px 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(15,23,42,0.04);
}

.af-admin-wrap .card-title {
  font-family: 'Poppins', system-ui, sans-serif;
}

/* Inputs */
.af-admin-wrap .field-input,
.af-admin-wrap .field-select,
.af-admin-wrap select.field-select,
.af-admin-wrap input.field-input,
.af-admin-wrap textarea.field-input {
  background: #f8fafc;
  border-color: #e2e8f0;
  line-height: 1.4;
  height: auto;
}

.af-admin-wrap .field-select option {
  background: #fff;
}

/* Buttons */
.af-admin-wrap .pill-button {
  line-height: 1.4;
  box-shadow: none;
  text-decoration: none;
}

.af-admin-wrap .pill-button.pill-primary {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}

.af-admin-wrap .pill-button.pill-primary:hover {
  background: #dc2626;
}

.af-admin-wrap .pill-button:focus {
  outline: 2px solid rgba(239,68,68,0.3);
  box-shadow: none;
}

/* Stats — Poppins numbers */
.af-admin-wrap .stat-value {
  font-family: 'Poppins', system-ui, sans-serif;
  font-weight: 700;
}

/* Copy Score Hero */
.af-copy-score-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0 12px;
}

.af-score-ring {
  position: relative;
  width: 120px;
  height: 120px;
}

.af-score-ring svg {
  transform: rotate(-90deg);
}

.af-score-ring .ring-bg {
  stroke: #e2e8f0;
}

.af-score-ring .ring-fill {
  transition: stroke-dashoffset 1s ease;
}

.af-score-number {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Poppins', system-ui, sans-serif;
  font-weight: 700;
  font-size: 32px;
  color: #111827;
}

.af-score-label {
  font-size: 11px;
  color: #6b7280;
  margin-top: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: 'Poppins', system-ui, sans-serif;
  font-weight: 600;
}

.af-score-detail {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 4px;
}

/* A/B VS Layout */
.af-ab-vs {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.af-ab-version {
  flex: 1;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 14px;
  text-align: center;
  position: relative;
}

.af-ab-version.winner {
  border-color: #16a34a;
  box-shadow: 0 0 12px rgba(22,163,74,0.1);
}

.af-ab-version .version-label {
  font-family: 'Poppins', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 6px;
}

.af-ab-version .version-score {
  font-family: 'Poppins', system-ui, sans-serif;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.af-ab-version .version-readers {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 4px;
}

.af-ab-version .crown {
  position: absolute;
  top: -10px;
  right: -6px;
  font-size: 18px;
}

.af-ab-vs-divider {
  display: flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #cbd5e1;
  padding: 0 2px;
}

/* Viewer micro-animations */
@keyframes af-hl-pulse {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}

.hl-just-saved {
  animation: af-hl-pulse 0.4s ease;
}

@keyframes af-pop-in {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.selection-popover:not(.hidden),
.thread-popover:not(.hidden) {
  animation: af-pop-in 0.12s ease;
}

/* Popover fade-out */
@keyframes af-fade-out {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(0.95); }
}

.af-fade-out {
  animation: af-fade-out 0.15s ease forwards;
  pointer-events: none;
}

/* Highlight marks — no animation or transition to prevent flash on re-render */

/* Audio sync highlight */
.af-audio-active {
  transition: background 0.25s ease;
}
.doc-block {
  transition: background 0.25s ease;
}

/* Audio player — remove tap/focus artifacts */
.af-audio-play,
.af-audio-scrub {
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
.af-audio-play:focus,
.af-audio-scrub:focus {
  outline: none;
  box-shadow: none;
}

/* Overt A/B — prevent horizontal scroll on mobile */
.af-embed-wrap {
  overflow-x: hidden;
}
.af-overt-panel {
  overflow-x: hidden;
}

/* Audio sync highlight — full width on mobile */
.af-audio-active {
  display: block;
  box-sizing: border-box;
}

@keyframes af-tick {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.af-tick-in {
  animation: af-tick 0.4s ease;
}
