/* =============================================================
   Polidis POC — app.css
   Aesthetic: editorial-institutional. Monochromatic base,
   amber annotation accent. Libre Baskerville + DM Sans.
   ============================================================= */

/* ── Custom properties ───────────────────────────────────────── */
:root {
  /* Base palette */
  --ink:        #1a1814;
  --ink-light:  #4a453d;
  --ink-muted:  #8a847a;
  --paper:      #f8f6f2;
  --paper-warm: #f2ede5;
  --rule:       #ddd9d2;
  --rule-light: #eae6df;

  /* Annotation amber */
  --amber:      #d4830a;
  --amber-soft: rgba(212, 131, 10, 0.18);
  --amber-glow: rgba(212, 131, 10, 0.32);
  --amber-dark: #a86208;

  /* UI */
  --danger:     #b03030;
  --danger-soft:rgba(176, 48, 48, 0.08);
  --radius:     4px;
  --sidebar-w:  340px;
  --toolbar-h:  48px;

  /* Typography */
  --font-serif:  'Libre Baskerville', Georgia, serif;
  --font-sans:   'DM Sans', system-ui, sans-serif;
  --font-mono:   'JetBrains Mono', 'Courier New', monospace;
}

/* ── Reset & base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font-sans);
  background: var(--paper);
  color: var(--ink);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Toolbar ──────────────────────────────────────────────────── */
.toolbar {
  height: var(--toolbar-h);
  min-height: var(--toolbar-h);
  background: var(--ink);
  color: #e8e2d8;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  z-index: 100;
}

.toolbar-brand {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-right: 20px;
  flex-shrink: 0;
}
.brand-mark {
  color: var(--amber);
  font-size: 16px;
  line-height: 1;
}
.brand-name {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 700;
  color: #f0ece4;
  letter-spacing: 0.01em;
}
.brand-tagline {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  font-weight: 300;
}

.toolbar-doc {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 8px;
  overflow: hidden;
  padding: 0 12px;
  border-left: 1px solid rgba(255,255,255,0.08);
  border-right: 1px solid rgba(255,255,255,0.08);
  margin-right: 12px;
  min-width: 0;
}
.doc-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  flex-shrink: 0;
}
.doc-name {
  font-size: 13px;
  color: #c8c2b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 400;
  padding: 5px 10px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, opacity 0.12s;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}
.btn-ghost {
  background: transparent;
  color: #b0a898;
  border: 1px solid rgba(255,255,255,0.1);
}
.btn-ghost:hover {
  background: rgba(255,255,255,0.08);
  color: #e0dcd4;
}
.btn-ghost.btn-danger:hover {
  background: var(--danger-soft);
  color: #e07070;
  border-color: rgba(176,48,48,0.3);
}
.btn-primary {
  background: var(--amber);
  color: white;
  font-weight: 500;
}
.btn-primary:hover { background: var(--amber-dark); }
.btn-secondary {
  background: var(--rule-light);
  color: var(--ink-light);
}
.btn-secondary:hover { background: var(--rule); }

/* ── Main layout ──────────────────────────────────────────────── */
.main-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ── PDF viewer column ────────────────────────────────────────── */
.viewer-column {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  background: #6b6660;
  /* Custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: #4a4540 #3a3530;
}
.viewer-column::-webkit-scrollbar { width: 8px; }
.viewer-column::-webkit-scrollbar-track { background: #3a3530; }
.viewer-column::-webkit-scrollbar-thumb { background: #5a5550; border-radius: 4px; }

.pdf-viewer {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 24px 60px;
  gap: 12px;
  min-height: 100%;
}

.viewer-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: #c0bab4;
  padding: 80px 0;
  font-size: 14px;
}
.loading-spinner {
  width: 28px;
  height: 28px;
  border: 2px solid rgba(255,255,255,0.15);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── PDF page wrapper ─────────────────────────────────────────── */
.pdf-page-wrapper {
  position: relative;
  background: white;
  box-shadow: 0 2px 12px rgba(0,0,0,0.35), 0 0 0 1px rgba(0,0,0,0.12);
  line-height: 0; /* prevent gap under canvas */
  transition: box-shadow 0.2s;
}
.pdf-page-wrapper.flash-page {
  box-shadow: 0 2px 20px rgba(212,131,10,0.5), 0 0 0 2px var(--amber);
}

/* ── PDF.js canvas ────────────────────────────────────────────── */
.pdf-page-wrapper canvas {
  display: block;
}

/* ── Text layer (PDF.js) ──────────────────────────────────────── */
.textLayer {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  overflow: hidden;
  line-height: 1;
  /* We let PDF.js set individual span positions */
}
.textLayer span,
.textLayer br {
  color: transparent;
  position: absolute;
  white-space: pre;
  cursor: text;
  transform-origin: 0% 0%;
  /* Allow text selection */
  user-select: text;
  -webkit-user-select: text;
}
.textLayer ::selection {
  background: rgba(70, 130, 200, 0.3);
  color: transparent;
}

/* ── Annotation highlights ────────────────────────────────────── */
.annotation-highlight {
  position: absolute;
  background: var(--amber-soft);
  border-bottom: 2px solid var(--amber);
  pointer-events: all;
  cursor: pointer;
  transition: background 0.15s;
  z-index: 5;
}
.annotation-highlight:hover {
  background: var(--amber-glow);
}
.annotation-highlight.flash-highlight {
  animation: highlightFlash 0.6s ease-out 2;
}
.deeplink-highlight {
  position: absolute;
  background: rgba(70, 130, 200, 0.28);
  border-bottom: 2px solid rgba(45, 100, 170, 0.9);
  pointer-events: none;
  z-index: 6;
  animation: deeplinkPulse 0.8s ease-in-out infinite alternate;
}
@keyframes deeplinkPulse {
  from { background: rgba(70, 130, 200, 0.18); }
  to   { background: rgba(70, 130, 200, 0.42); }
}
@keyframes highlightFlash {
  0%   { background: var(--amber-glow); }
  50%  { background: rgba(212,131,10,0.5); }
  100% { background: var(--amber-soft); }
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  max-width: var(--sidebar-w);
  background: var(--paper);
  border-left: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}
.sidebar-title {
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  flex: 1;
}
.sidebar-count {
  font-size: 11px;
  font-weight: 500;
  background: var(--ink);
  color: var(--paper);
  border-radius: 20px;
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
}
/* Grip + close button only appear in the mobile bottom-sheet mode */
.sidebar-grip { display: none; }
.sidebar-close {
  display: none;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--ink-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  border-radius: 3px;
  align-items: center;
  justify-content: center;
}
.sidebar-close:hover { background: var(--rule-light); color: var(--ink); }

.sidebar-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--ink-muted);
  padding: 40px 24px;
  text-align: center;
}
.empty-icon {
  font-size: 24px;
  color: var(--rule);
}
.sidebar-empty p {
  font-size: 13px;
  line-height: 1.6;
}

.annotation-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}

/* ── Annotation card ──────────────────────────────────────────── */
.annotation-card {
  padding: 12px 18px;
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  position: relative;
}
.annotation-card:hover {
  background: var(--paper-warm);
  border-left-color: var(--amber);
}
.annotation-card.is-active {
  background: var(--paper-warm);
  border-left-color: var(--amber);
}
.annotation-card + .annotation-card {
  border-top: 1px solid var(--rule-light);
}

.card-quote {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--ink-light);
  background: var(--paper-warm);
  border-left: 2px solid var(--amber);
  padding: 4px 8px;
  margin-bottom: 8px;
  border-radius: 0 2px 2px 0;
  /* Truncate long quotes */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-orphaned .card-quote {
  border-left-color: var(--ink-muted);
  opacity: 0.7;
}

.card-body {
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
  margin-bottom: 8px;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-author {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-light);
}
.card-date {
  font-size: 11px;
  color: var(--ink-muted);
}
.card-replies {
  margin-left: auto;
  border: 1px solid var(--rule);
  background: none;
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.card-replies:hover {
  color: var(--amber-dark);
  border-color: var(--amber);
  background: var(--amber-soft);
}
.card-replies.has-replies {
  color: var(--amber-dark);
  border-color: var(--amber-glow);
  background: var(--amber-soft);
}

.card-page {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--ink-muted);
  background: var(--rule-light);
  padding: 1px 5px;
  border-radius: 2px;
}
.card-orphan-badge {
  font-size: 10px;
  color: var(--ink-muted);
  font-style: italic;
}

.card-delete {
  position: absolute;
  top: 10px;
  right: 14px;
  width: 20px;
  height: 20px;
  border: none;
  background: none;
  color: var(--ink-muted);
  cursor: pointer;
  border-radius: 2px;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  transition: color 0.12s, background 0.12s;
}
.annotation-card:hover .card-delete {
  display: flex;
}
.card-delete:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

/* ── Selection popover ────────────────────────────────────────── */
.popover {
  position: fixed;
  z-index: 200;
  pointer-events: all;
}
.popover[hidden] { display: none; }
.popover-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  background: var(--ink);
  color: #e8e2d8;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35), 0 1px 3px rgba(0,0,0,0.2);
  transition: background 0.12s, transform 0.1s;
  white-space: nowrap;
}
.popover-btn:hover {
  background: #2e2a25;
  transform: translateY(-1px);
}
/* Triangle arrow below */
.popover-btn::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--ink);
}

/* ── Compose modal ────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26,24,20,0.55);
  backdrop-filter: blur(2px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-backdrop[hidden] { display: none; }

.modal {
  background: var(--paper);
  border-radius: 6px;
  width: 480px;
  max-width: calc(100vw - 40px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.3), 0 0 0 1px rgba(0,0,0,0.08);
  animation: modalIn 0.18s cubic-bezier(0.34, 1.2, 0.64, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--rule-light);
}
.modal-title {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 700;
  flex: 1;
}
.modal-close {
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  color: var(--ink-muted);
  cursor: pointer;
  font-size: 18px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
}
.modal-close:hover { background: var(--rule-light); color: var(--ink); }

.modal-quote {
  margin: 12px 20px;
  padding: 8px 12px;
  background: var(--paper-warm);
  border-left: 3px solid var(--amber);
  border-radius: 0 3px 3px 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--ink-light);
  max-height: 80px;
  overflow-y: auto;
}

.modal-body {
  padding: 4px 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.form-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
}
.form-input,
.form-textarea {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: white;
  color: var(--ink);
  transition: border-color 0.12s;
  outline: none;
  resize: none;
}
.form-input:focus,
.form-textarea:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 2px var(--amber-soft);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--rule-light);
}

/* ── Toast notifications ──────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  align-items: center;
}
.toast {
  background: var(--ink);
  color: #e8e2d8;
  font-size: 12px;
  padding: 8px 16px;
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  animation: toastIn 0.2s ease, toastOut 0.3s ease 2.5s forwards;
  white-space: nowrap;
}
.toast.toast-error {
  background: var(--danger);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(-4px); }
}

/* ── Thread dialog ────────────────────────────────────────────── */
.thread-modal {
  width: 560px;
  display: flex;
  flex-direction: column;
  max-height: min(80dvh, 720px);
}
.thread-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 20px 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}

.thread-node.is-root > .thread-comment {
  border-left: 3px solid var(--amber);
  background: var(--paper-warm);
  border-radius: 0 4px 4px 0;
  padding: 10px 12px;
  margin-bottom: 4px;
}
.thread-comment {
  padding: 8px 0;
}
.thread-comment-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 3px;
}
.thread-author {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-light);
}
.thread-date {
  font-size: 11px;
  color: var(--ink-muted);
}
.thread-root-badge {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--amber-dark);
  background: var(--amber-soft);
  padding: 1px 6px;
  border-radius: 2px;
}
.thread-comment-body {
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-wrap;
}
.thread-comment-actions {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}
.thread-action {
  border: none;
  background: none;
  padding: 2px 0;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-muted);
  cursor: pointer;
  transition: color 0.12s;
}
.thread-action:hover { color: var(--amber-dark); }
.thread-action-danger:hover { color: var(--danger); }

/* Nesting: each reply's children indent under it with a guide line */
.thread-children {
  margin-left: 14px;
  padding-left: 12px;
  border-left: 1px solid var(--rule-light);
}
.thread-children:empty { display: none; }

.thread-inline-form {
  margin: 6px 0 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.thread-inline-form[hidden] { display: none; }
.thread-inline-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}
.btn-sm { padding: 4px 10px; font-size: 11px; }

.thread-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--rule-light);
}
.thread-composer .form-textarea { flex: 1; }

/* ── Mobile FAB + bottom sheet scrim ──────────────────────────── */
.fab {
  display: none;
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 240;
  align-items: center;
  gap: 7px;
  padding: 12px 16px;
  border: none;
  border-radius: 28px;
  background: var(--ink);
  color: #e8e2d8;
  font-family: var(--font-sans);
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
}
.fab-icon { font-size: 16px; line-height: 1; }
.fab-count {
  font-size: 12px;
  font-weight: 500;
  background: var(--amber);
  color: white;
  border-radius: 20px;
  padding: 1px 8px;
  min-width: 22px;
  text-align: center;
}

.sheet-scrim {
  position: fixed;
  inset: 0;
  background: rgba(26,24,20,0.4);
  z-index: 245;
}
.sheet-scrim[hidden] { display: none; }

/* ── Responsive: mobile layout ────────────────────────────────── */
@media (max-width: 900px) {
  /* Toolbar: brand + icon-only buttons */
  .brand-tagline, .toolbar-doc, .btn-label { display: none; }
  .toolbar { padding: 0 10px; }
  .toolbar-brand { flex: 1; margin-right: 0; }
  .btn-ghost { padding: 7px 9px; }

  .pdf-viewer { padding: 10px 8px 90px; gap: 8px; }

  /* Sidebar becomes a bottom sheet behind the FAB */
  .fab { display: inline-flex; }
  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    min-width: 0;
    max-width: none;
    height: 72dvh;
    z-index: 250;
    border-left: none;
    border-top: 1px solid var(--rule);
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -8px 30px rgba(0,0,0,0.25);
    transform: translateY(105%);
    transition: transform 0.25s cubic-bezier(0.32, 0.72, 0.25, 1);
  }
  .sidebar.is-open { transform: translateY(0); }
  .sidebar-header { position: relative; padding-top: 20px; }
  .sidebar-grip {
    display: block;
    position: absolute;
    top: 7px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--rule);
  }
  .sidebar-close { display: flex; }

  /* Delete button always visible (no hover on touch) */
  .card-delete { display: flex; }

  /* Modals hug the bottom of small screens */
  .modal-backdrop { align-items: flex-end; }
  .modal {
    width: 100%;
    max-width: 100%;
    border-radius: 14px 14px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .thread-modal { max-height: 86dvh; }
}

/* ── Touch refinements ────────────────────────────────────────── */
@media (pointer: coarse) {
  /* 16px inputs prevent iOS Safari from zooming the page on focus */
  .form-input, .form-textarea { font-size: 16px; }
  .popover-btn { padding: 10px 16px; font-size: 14px; }
  .thread-action { padding: 6px 0; font-size: 12px; }
  .card-replies { padding: 4px 10px; }
}

/* =============================================================
   Prototype additions — auth, dashboard, moderation, statuses
   ============================================================= */

/* Pages that scroll normally (dashboard, login, moderation) */
body.page {
  overflow: auto;
  height: auto;
  min-height: 100dvh;
}
.page-main {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}
.page-heading {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 18px;
}
.page-heading h1 {
  font-family: var(--font-serif);
  font-size: 22px;
  color: var(--ink);
}
.page-heading .sub {
  font-size: 12px;
  color: var(--ink-muted);
}
.page-heading .spacer { flex: 1; }

/* Toolbar user chip */
.toolbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #c8c2b8;
}
.user-chip .role-badge {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: var(--amber);
  color: white;
  padding: 1px 6px;
  border-radius: 2px;
}
.toolbar a.btn { color: #b0a898; }

/* Login */
.login-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 380px;
  max-width: 100%;
  background: white;
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.08);
}
.login-brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}
.login-brand .brand-mark { font-size: 20px; }
.login-brand .brand-name { color: var(--ink); font-size: 20px; }
.login-sub {
  font-size: 12px;
  color: var(--ink-muted);
  margin-bottom: 20px;
}
.login-card .form-label { margin-top: 12px; display: block; }
.login-card .form-input { margin-top: 4px; }
.login-card .btn-primary {
  width: 100%;
  justify-content: center;
  margin-top: 18px;
  padding: 9px;
  font-size: 13px;
}
.login-error {
  color: var(--danger);
  font-size: 12px;
  margin-top: 10px;
  min-height: 16px;
}
.login-hint {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--rule-light);
  font-size: 11px;
  line-height: 1.7;
  color: var(--ink-muted);
}
.login-hint code {
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: var(--paper-warm);
  padding: 1px 4px;
  border-radius: 2px;
}

/* Document cards (dashboard) */
.doc-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.doc-card {
  display: block;
  background: white;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 16px 18px;
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.doc-card:hover {
  border-color: var(--amber);
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}
.doc-card-top {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.doc-card-title {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 700;
  flex: 1;
}
.doc-card-desc {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink-light);
  margin-top: 6px;
}
.doc-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  font-size: 11px;
  color: var(--ink-muted);
}
.doc-card-meta .mono { font-family: var(--font-mono); font-size: 10px; }
.chip {
  display: inline-block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--rule-light);
  color: var(--ink-light);
}
.chip-amber { background: var(--amber-soft); color: var(--amber-dark); }
.empty-note {
  text-align: center;
  color: var(--ink-muted);
  font-size: 13px;
  padding: 60px 0;
}

/* Status badges on annotation cards & moderation queue */
.status-badge {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 1px 6px;
  border-radius: 2px;
  white-space: nowrap;
}
.status-draft     { background: var(--rule-light); color: var(--ink-light); }
.status-pending   { background: rgba(70,110,180,0.12); color: #3a5a90; }
.status-rejected  { background: var(--danger-soft); color: var(--danger); }
.status-friends   { background: rgba(90,140,90,0.12); color: #4a7a4a; }

.card-publish {
  border: 1px solid var(--amber);
  background: var(--amber-soft);
  color: var(--amber-dark);
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.12s;
}
.card-publish:hover { background: var(--amber-glow); }

/* Draft/pending highlights are visually distinct from published ones */
.annotation-highlight.hl-draft   { border-bottom-style: dashed; background: rgba(138,132,122,0.16); border-bottom-color: var(--ink-muted); }
.annotation-highlight.hl-pending { border-bottom-style: dotted; }
.annotation-highlight.hl-rejected{ background: var(--danger-soft); border-bottom-color: var(--danger); }

/* Moderation queue */
.queue-section { margin-bottom: 28px; }
.queue-section h2 {
  font-family: var(--font-serif);
  font-size: 15px;
  margin-bottom: 10px;
}
.queue-card {
  background: white;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.queue-quote {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--ink-light);
  background: var(--paper-warm);
  border-left: 2px solid var(--amber);
  padding: 4px 8px;
  margin-bottom: 8px;
  border-radius: 0 2px 2px 0;
}
.queue-context {
  font-size: 11.5px;
  color: var(--ink-muted);
  margin-bottom: 6px;
  font-style: italic;
}
.queue-body { font-size: 13px; line-height: 1.55; margin-bottom: 10px; }
.queue-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--ink-muted);
}
.queue-meta .spacer { flex: 1; }
.btn-approve {
  background: #4a7a4a;
  color: white;
  font-weight: 500;
}
.btn-approve:hover { background: #3d663d; }
.btn-reject {
  background: none;
  border: 1px solid var(--rule);
  color: var(--danger);
}
.btn-reject:hover { background: var(--danger-soft); border-color: var(--danger); }

/* Compose modal: visibility selector */
.visibility-row {
  display: flex;
  gap: 8px;
}
.visibility-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 8px 10px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.visibility-option:has(input:checked) {
  border-color: var(--amber);
  background: var(--amber-soft);
}
.visibility-option input { display: none; }
.visibility-option .v-title { font-size: 12px; font-weight: 500; color: var(--ink); }
.visibility-option .v-desc  { font-size: 10.5px; color: var(--ink-muted); line-height: 1.4; }

/* Thread dialog: pending replies */
.thread-comment.is-pending { opacity: 0.75; }

/* Upload dialog reuses .modal; form grid */
.form-row { display: flex; gap: 10px; }
.form-row > div { flex: 1; }
.upload-file-label {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 12px;
  color: var(--ink-light);
  cursor: pointer;
  transition: border-color 0.12s;
}
.upload-file-label:hover { border-color: var(--amber); }
