/* ===== CSS Custom Properties ===== */
:root {
  /* Primary palette — Steel Navy */
  --color-primary: #2b4c7e;
  --color-primary-light: #3a6298;
  --color-primary-lighter: #5a8abf;
  --color-primary-tint: #e8f0f8;

  /* Backgrounds */
  --color-bg: #f7f8fa;
  --color-bg-document: #d5d8dc;
  --color-bg-card: #ffffff;
  --color-bg-annotation-panel: #fdfcf8;

  /* Text */
  --color-text: #2d3748;
  --color-text-secondary: #718096;
  --color-text-on-primary: #ffffff;

  /* Accents */
  --color-gold: #b7950b;
  --color-error: #e53e3e;
  --color-success: #38a169;

  /* Highlights */
  --color-highlight-yellow: #fef3cd;
  --color-highlight-green: #d4edda;
  --color-highlight-blue: #cce5ff;
  --color-highlight-pink: #f8bbd0;
  --color-highlight-orange: #ffeaa7;

  /* Typography */
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;
  --font-mono: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;

  /* Layout */
  --topbar-height: 56px;
  --sidebar-left-width: 250px;
  --sidebar-right-width: 260px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 200ms ease;
  --transition-glow: 500ms ease;
}

/* ============================================================
   Case Law Search — Main Stylesheet
   Palette: var(--color-bg) bg · var(--color-text) text · var(--color-primary) navy · var(--color-gold) gold
   ============================================================ */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-ui);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  color: var(--color-gold);
}

button {
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
}

input, select, textarea {
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--color-text);
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: #edf2f7;
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

/* Screen-reader only utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Topbar ===== */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: var(--color-primary);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  z-index: 1000;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.topbar-brand {
  color: var(--color-text-on-primary);
  font-size: 1.1rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.topbar-brand:hover {
  opacity: 0.9;
}

.topbar-hamburger {
  color: var(--color-text-on-primary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
}

.topbar-hamburger:hover {
  background: rgba(255, 255, 255, 0.15);
}

.topbar-search {
  flex: 1;
  max-width: 600px;
  display: flex;
  align-items: center;
  gap: 0;
  margin: 0 auto;
}

.search-input {
  flex: 1;
  padding: 8px 14px;
  border: none;
  border-radius: 4px 0 0 4px;
  font-size: 14px;
  font-family: var(--font-ui);
  background: rgba(255, 255, 255, 0.95);
  color: var(--color-text);
  outline: none;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08);
}

.search-input:focus {
  background: #fff;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.search-input::placeholder {
  color: #a0aec0;
}

.btn-filter-toggle {
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.95);
  border: none;
  border-left: 1px solid #e2e8f0;
  color: var(--color-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
}

.btn-filter-toggle:hover,
.btn-filter-toggle.active {
  color: var(--color-primary);
  background: var(--color-primary-tint);
}

.btn-search {
  padding: 8px 18px;
  background: var(--color-gold);
  color: #fff;
  border: none;
  border-radius: 0 4px 4px 0;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}

.btn-search:hover {
  background: #a07e0a;
}

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

.topbar-right .btn-icon {
  color: var(--color-text-on-primary);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-ui);
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
  line-height: 1.4;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-text-on-primary);
  border-color: var(--color-primary);
}

.btn-primary:hover {
  background: #1f3a61;
  border-color: #1f3a61;
}

.btn-outline {
  background: var(--color-bg-card);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.btn-outline:hover {
  background: var(--color-primary);
  color: var(--color-text-on-primary);
}

.btn-danger {
  background: var(--color-bg-card);
  color: var(--color-error);
  border-color: var(--color-error);
}

.btn-danger:hover {
  background: var(--color-error);
  color: #fff;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-xs {
  padding: 2px 8px;
  font-size: 11px;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 4px;
  color: var(--color-text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.btn-icon:hover {
  background: var(--color-primary-tint);
  color: var(--color-primary);
}

/* ===== Filters Panel ===== */
.filters-panel {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  right: 0;
  background: var(--color-bg-card);
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
  z-index: 999;
  padding: 16px 24px;
  max-height: calc(100vh - var(--topbar-height) - 40px);
  overflow-y: auto;
}

.filters-panel-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.filter-row {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

/* Court filter grid */
.filter-group-wide {
  width: 100%;
  flex: none;
}

.filter-group-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-primary);
  margin-bottom: 8px;
  display: block;
}

.court-filter-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.court-filter-section {
  padding: 0;
}

.court-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text);
  margin: 0 0 6px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.court-section-toggle {
  background: none;
  border: none;
  font-size: 11px;
  color: var(--color-primary-lighter);
  cursor: pointer;
  padding: 0;
  font-family: var(--font-ui);
}

.court-section-toggle:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

.court-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 2px 12px;
}

.court-checkbox {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--color-text);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  transition: background var(--transition-fast);
}

.court-checkbox:hover {
  background: var(--color-primary-tint);
}

.court-checkbox input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--color-primary);
  cursor: pointer;
  margin: 0;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 140px;
}

.filter-group label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
}

.filter-input {
  padding: 6px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 13px;
  font-family: var(--font-ui);
  color: var(--color-text);
  outline: none;
}

.filter-input:focus {
  border-color: var(--color-primary-lighter);
  box-shadow: 0 0 0 2px var(--color-primary-tint);
}

.filter-actions {
  display: flex;
  align-items: flex-end;
  padding-bottom: 1px;
}

/* Filter summary bar (shown when filters are minimized but active) */
.filter-summary-bar {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  right: 0;
  background: var(--color-primary-tint);
  border-bottom: 1px solid #c9d8ea;
  z-index: 998;
  padding: 6px 24px;
  font-size: 12px;
}

.filter-summary-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.filter-summary-text {
  color: var(--color-primary);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-summary-edit {
  background: none;
  border: none;
  color: var(--color-primary-lighter);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-family: var(--font-ui);
  white-space: nowrap;
  flex-shrink: 0;
}

.filter-summary-edit:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

.filter-minimize-btn {
  margin-left: 8px;
}

/* ===== Layout ===== */
.layout-wrapper {
  display: flex;
  min-height: calc(100vh - var(--topbar-height));
  margin-top: var(--topbar-height);
}

/* ===== Sidebars ===== */
.sidebar {
  position: sticky;
  top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height));
  overflow-y: auto;
  flex-shrink: 0;
  transition: width var(--transition-normal), min-width var(--transition-normal);
}

.sidebar-left {
  width: var(--sidebar-left-width);
  min-width: var(--sidebar-left-width);
  background: var(--color-bg-card);
  border-right: 1px solid #e2e8f0;
}

.sidebar-left.collapsed {
  width: 0;
  min-width: 0;
  overflow: hidden;
  border-right: none;
}

.sidebar-right {
  width: var(--sidebar-right-width);
  min-width: var(--sidebar-right-width);
  background: var(--color-bg-annotation-panel);
  border-left: 1px solid #e8e0c8;
}

.sidebar-right.collapsed {
  width: 0;
  min-width: 0;
  overflow: hidden;
  border-left: none;
}

.sidebar-section {
  padding: 12px 16px;
  border-bottom: 1px solid #edf2f7;
}

.sidebar-section:last-child {
  border-bottom: none;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.sidebar-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-primary);
  margin: 0;
}

.sidebar-filter {
  margin-bottom: 8px;
}

.sidebar-filter-input {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 12px;
  font-family: var(--font-ui);
  outline: none;
}

.sidebar-filter-input:focus {
  border-color: var(--color-primary-lighter);
  box-shadow: 0 0 0 2px var(--color-primary-tint);
}

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  min-width: 0;
  background: var(--color-bg);
  padding: 1.5rem 2rem;
}

.sidebar[hidden] {
  display: none;
}

/* Remove padding from main-content when document viewer is present */
.main-content:has(.document-viewer-bg) {
  padding: 0;
}

/* ===== Document Viewer ===== */
.document-viewer-bg {
  background: var(--color-bg-document);
  min-height: calc(100vh - var(--topbar-height));
  padding: 24px 0;
}

.document-column {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 24px;
}

.document-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.document-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.document-page {
  background: var(--color-bg-card);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.12);
  border-radius: 2px;
  padding: 48px;
}

/* Court Header */
.document-court-header {
  text-align: center;
  margin-bottom: 8px;
}

.court-name {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}

.docket-number {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-bottom: 12px;
}

.document-court-header .case-name {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 8px 0;
  line-height: 1.4;
}

.date-decided {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--color-text-secondary);
}

.document-rule {
  border: none;
  border-top: 1px solid #cbd5e0;
  margin: 16px 0;
}

.judge-line {
  font-family: var(--font-serif);
  font-size: 14px;
  font-style: italic;
  color: var(--color-text-secondary);
  margin-bottom: 24px;
}

/* Opinion Body Typography */
.opinion-body {
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.8;
  color: var(--color-text);
  text-align: justify;
}

.opinion-body p {
  text-indent: 2em;
  margin-bottom: 1.1em;
}

.opinion-body p:first-child,
.opinion-body h2 + p,
.opinion-body h3 + p,
.opinion-body h4 + p,
.opinion-body .court-header-line + p {
  text-indent: 0;
}

.opinion-body h2, .opinion-body h3, .opinion-body h4 {
  font-family: var(--font-ui);
  font-variant: small-caps;
  color: var(--color-primary);
  margin: 1.5em 0 0.5em 0;
  text-indent: 0;
}

.opinion-body h2 { font-size: 1.15rem; }
.opinion-body h3 { font-size: 1.05rem; }
.opinion-body h4 { font-size: 1rem; }

.opinion-body blockquote {
  margin: 1em 2em;
  padding-left: 1em;
  border-left: 3px solid #cbd5e0;
  font-size: 0.95rem;
  color: var(--color-text-secondary);
}

.opinion-body .court-header-line {
  text-align: center;
  text-indent: 0;
  font-weight: 700;
  font-family: var(--font-ui);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-secondary);
  margin: 0.5em 0;
}

.opinion-body a {
  color: var(--color-primary-lighter);
  text-decoration: underline;
}

.opinion-body a.citation-link {
  text-decoration-style: dashed;
}

.opinion-body a:hover {
  color: var(--color-primary);
}

/* Star pagination page numbers — matches both class and custom element tag */
.opinion-body .page-number,
.opinion-body page-number {
  display: inline;
  font-size: 10px;
  color: var(--color-text-secondary);
  background: #f7fafc;
  border: 1px solid #e2e8f0;
  border-radius: 3px;
  padding: 0 4px;
  margin: 0 2px;
  vertical-align: middle;
  white-space: nowrap;
}

/* Footnotes section (extracted from inline page-break footnotes) */
.footnote-separator {
  margin: 24px 0 12px 0;
  border: none;
  border-top: 1px solid #cbd5e0;
}

.footnotes-section {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
}

.footnote-text {
  margin-bottom: 8px;
  padding-left: 16px;
  text-indent: -16px;
}

.footnote-num {
  font-weight: 600;
  color: var(--color-primary-lighter);
  margin-right: 4px;
}

/* Footnote superscripts */
.opinion-body .footnote-ref {
  color: var(--color-primary-lighter);
  cursor: pointer;
  font-size: 0.75em;
  vertical-align: super;
  font-weight: 700;
  text-decoration: none;
}

.opinion-body .footnote-ref:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

/* Pre tag handling (fallback for plain-text opinions) */
.opinion-body pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.8;
  text-align: justify;
  margin: 0;
  padding: 0;
}

/* ===== Footnote Popover ===== */
.footnote-popover {
  position: absolute;
  z-index: 1500;
  background: var(--color-bg-card);
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  max-width: 400px;
  max-height: 300px;
  overflow-y: auto;
  padding: 12px 16px;
  font-family: var(--font-serif);
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text);
  animation: fadeIn var(--transition-fast);
}

.footnote-popover-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  font-size: 18px;
  color: var(--color-text-secondary);
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
}

.footnote-popover-close:hover {
  color: var(--color-text);
}

.footnote-popover .footnote-num {
  color: var(--color-primary);
  font-weight: 700;
  margin-right: 4px;
}

/* ===== Skeleton Loading ===== */
.skeleton {
  background: linear-gradient(90deg, #e2e8f0 25%, #edf2f7 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
  margin-bottom: 12px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-header {
  height: 24px;
  width: 40%;
  margin: 0 auto 20px auto;
}

.skeleton-line {
  height: 14px;
  width: 100%;
}

/* ===== Annotation Count Badge ===== */
.annotation-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--color-primary-tint);
  color: var(--color-primary);
  font-size: 11px;
  font-weight: 700;
  border-radius: 10px;
}

/* ===== Annotation Filter Dots ===== */
.ann-filter-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* ===== Folder Tree ===== */
.folder-tree-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.folder-tree-list .folder-tree-list {
  padding-left: 16px;
}

.folder-tree-item {
  margin-bottom: 1px;
}

.folder-tree-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 4px;
  text-decoration: none;
  color: var(--color-text);
  font-size: 13px;
  transition: background var(--transition-fast);
}

.folder-tree-link:hover {
  background: var(--color-primary-tint);
}

.folder-tree-link.active {
  background: var(--color-primary-tint);
  color: var(--color-primary);
  font-weight: 600;
}

.folder-tree-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.folder-tree-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-tree-count {
  font-size: 11px;
  color: var(--color-text-secondary);
  background: var(--color-bg);
  padding: 1px 6px;
  border-radius: 8px;
  flex-shrink: 0;
}

.folder-tree-actions {
  display: none;
  gap: 2px;
}

.folder-tree-item:hover .folder-tree-actions {
  display: flex;
}

.folder-tree-action-btn {
  background: none;
  border: none;
  font-size: 14px;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 0 3px;
  line-height: 1;
}

.folder-tree-action-btn:hover {
  color: var(--color-primary);
}

/* ── Search History ───────────────────────────────────────── */
.search-history {
  padding: 0 0.5rem;
}

.search-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  color: var(--color-text);
  font-size: 13px;
  transition: background var(--transition-fast);
}

.search-history-item:hover {
  background: var(--color-primary-tint);
}

.search-history-query {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.search-history-count {
  font-size: 11px;
  color: var(--color-text-secondary);
  flex-shrink: 0;
  margin-left: 8px;
}

/* ── Search Results ───────────────────────────────────────── */
.search-results-container {
  max-width: 860px;
}

.search-status {
  font-size: 0.875rem;
  color: #718096;
  margin-bottom: 1rem;
  padding: 0.4rem 0;
}

.search-status[hidden] {
  display: none;
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* ===== Search Results (Dense List) ===== */
.search-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  margin-bottom: 4px;
  font-size: 13px;
  color: var(--color-text-secondary);
}

.results-table {
  width: 100%;
  border-collapse: collapse;
}

.results-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
}

.result-row {
  border-bottom: 1px solid #edf2f7;
  transition: background var(--transition-fast);
}

.result-row:nth-child(even) {
  background: #f8f9fa;
}

.result-row:hover {
  background: var(--color-primary-tint);
}

.result-row td {
  padding: 10px 12px;
  font-size: 13px;
  vertical-align: top;
}

.result-case-link {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.4;
}

.result-case-link:hover {
  text-decoration: underline;
  color: var(--color-primary-light);
}

.result-citation {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-text);
  white-space: nowrap;
}

.result-court {
  font-size: 12px;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.result-date {
  font-size: 12px;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.result-snippet {
  font-size: 12px;
  color: var(--color-text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  padding: 4px 12px 8px 12px;
}

.result-snippet mark {
  background: var(--color-highlight-yellow);
  padding: 0 1px;
  border-radius: 2px;
}

/* Search skeleton */
.results-skeleton .skeleton-row {
  display: flex;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid #edf2f7;
}

.results-skeleton .skeleton-row .skeleton {
  margin: 0;
}

/* ── Pagination ───────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px 0;
}

.pagination[hidden] {
  display: none;
}

.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  font-size: 13px;
  font-family: var(--font-ui);
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  background: var(--color-bg-card);
  color: var(--color-text);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pagination-btn:hover {
  background: var(--color-primary-tint);
  border-color: var(--color-primary-lighter);
  color: var(--color-primary);
}

.pagination-btn.active {
  background: var(--color-primary);
  color: var(--color-text-on-primary);
  border-color: var(--color-primary);
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination-ellipsis {
  padding: 0 4px;
  color: var(--color-text-secondary);
}

/* ── Highlight Colors ─────────────────────────────────────── */

/* ===== Annotation Toolbar (Floating) ===== */
.annotation-toolbar {
  position: absolute;
  z-index: 1500;
  background: var(--color-bg-card);
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  animation: fadeIn var(--transition-fast);
}

.annotation-toolbar[hidden] {
  display: none;
}

.color-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.color-btn:hover {
  transform: scale(1.15);
  border-color: var(--color-primary-lighter);
}

.color-btn.color-yellow { background: var(--color-highlight-yellow); }
.color-btn.color-green  { background: var(--color-highlight-green); }
.color-btn.color-blue   { background: var(--color-highlight-blue); }
.color-btn.color-pink   { background: var(--color-highlight-pink); }
.color-btn.color-orange { background: var(--color-highlight-orange); }

.toolbar-sep {
  width: 1px;
  height: 20px;
  background: #e2e8f0;
  margin: 0 2px;
}

.toolbar-btn {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 4px;
  transition: background var(--transition-fast);
}

.toolbar-btn:hover {
  background: var(--color-primary-tint);
}

/* Annotation Highlights */
.annotation-highlight {
  border-radius: 2px;
  cursor: pointer;
  transition: box-shadow var(--transition-fast);
}

.annotation-highlight:hover {
  box-shadow: 0 0 0 2px rgba(43, 76, 126, 0.25);
}

.annotation-color-yellow { background: var(--color-highlight-yellow); }
.annotation-color-green { background: var(--color-highlight-green); }
.annotation-color-blue { background: var(--color-highlight-blue); }
.annotation-color-pink { background: var(--color-highlight-pink); }
.annotation-color-orange { background: var(--color-highlight-orange); }

@keyframes highlightPulse {
  0% { box-shadow: 0 0 0 0 rgba(43, 76, 126, 0.3); }
  50% { box-shadow: 0 0 8px 3px rgba(43, 76, 126, 0.3); }
  100% { box-shadow: 0 0 0 0 rgba(43, 76, 126, 0.3); }
}

mark.annotation-highlight.pulse {
  animation: highlightPulse var(--transition-glow);
}

/* ===== Annotation Panel (Right Sidebar) ===== */
.annotation-filter-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.ann-filter-btn {
  padding: 3px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: var(--color-bg-card);
  font-size: 11px;
  font-family: var(--font-ui);
  cursor: pointer;
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ann-filter-btn.active {
  background: var(--color-primary-tint);
  color: var(--color-primary);
  border-color: var(--color-primary-lighter);
}

.ann-filter-btn:hover {
  border-color: var(--color-primary-lighter);
}

.annotations-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.annotation-card {
  background: var(--color-bg-card);
  border-radius: 6px;
  border-left: 4px solid #e2e8f0;
  padding: 8px 10px;
  cursor: pointer;
  transition: outline var(--transition-fast), box-shadow var(--transition-fast);
}

.annotation-card:hover {
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.annotation-card.annotation-card-active {
  outline: 2px solid var(--color-primary-lighter);
  box-shadow: 0 0 8px rgba(43, 76, 126, 0.15);
}

.annotation-card[data-color="yellow"] { border-left-color: var(--color-highlight-yellow); }
.annotation-card[data-color="green"] { border-left-color: var(--color-highlight-green); }
.annotation-card[data-color="blue"] { border-left-color: var(--color-highlight-blue); }
.annotation-card[data-color="pink"] { border-left-color: var(--color-highlight-pink); }
.annotation-card[data-color="orange"] { border-left-color: var(--color-highlight-orange); }

.annotation-excerpt {
  font-family: var(--font-serif);
  font-size: 12px;
  line-height: 1.5;
  color: var(--color-text);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}

.annotation-note {
  font-size: 11px;
  color: var(--color-text-secondary);
  font-style: italic;
  margin-bottom: 4px;
}

.annotation-actions {
  display: none;
  gap: 8px;
  margin-top: 4px;
}

.annotation-card:hover .annotation-actions {
  display: flex;
}

.annotation-action-btn {
  background: none;
  border: none;
  font-size: 11px;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 2px 0;
  font-family: var(--font-ui);
}

.annotation-action-btn:hover {
  color: var(--color-primary);
}

.annotation-action-btn.delete:hover {
  color: var(--color-error);
}

.annotation-empty {
  text-align: center;
  padding: 24px 16px;
  color: var(--color-text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

/* ===== Dropdowns ===== */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 180px;
  background: var(--color-bg-card);
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 100;
  padding: 4px 0;
}

.dropdown-menu[hidden] {
  display: none;
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--color-text);
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-ui);
}

.dropdown-item:hover {
  background: var(--color-primary-tint);
  color: var(--color-primary);
}

.dropdown-item.active {
  background: #dbeafe;
  font-weight: 600;
  color: var(--color-primary);
}

.dropdown-divider {
  height: 1px;
  background: #e2e8f0;
  margin: 0.25rem 0;
}

/* ===== Modals ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeIn var(--transition-fast);
}

.modal-overlay[hidden] {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--color-bg-card);
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
  width: 90%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-wide {
  max-width: 600px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid #edf2f7;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--color-text);
}

.modal-body {
  padding: 16px 24px;
}

.modal-footer {
  padding: 12px 24px;
  border-top: 1px solid #edf2f7;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ===== Folder View ===== */
.folder-view {
  max-width: 900px;
  margin: 0 auto;
}

.folder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.folder-header-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.folder-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}

.folder-header-actions {
  display: flex;
  gap: 8px;
}

.folder-empty {
  text-align: center;
  padding: 40px;
  color: var(--color-text-secondary);
  font-size: 14px;
}

/* ===== Forms ===== */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 4px;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #4a5568;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 14px;
  font-family: var(--font-ui);
  color: var(--color-text);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
  border-color: var(--color-primary-lighter);
  box-shadow: 0 0 0 2px var(--color-primary-tint);
}

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

/* ===== Empty & Error States ===== */
.empty-state {
  text-align: center;
  padding: 40px 24px;
  color: var(--color-text-secondary);
}

.empty-state p {
  font-size: 14px;
  line-height: 1.6;
  margin: 0;
}

.error-state {
  text-align: center;
  padding: 40px 24px;
  color: var(--color-error);
}

.error-state p {
  font-size: 14px;
  line-height: 1.6;
  margin: 0;
}

.error-banner {
  background: #fff5f5;
  border: 1px solid #fc8181;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  color: #c53030;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

/* ===== Scrollbars ===== */
.sidebar::-webkit-scrollbar,
.footnote-popover::-webkit-scrollbar,
.modal::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.annotations-list::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track,
.footnote-popover::-webkit-scrollbar-track,
.modal::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track,
.annotations-list::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb,
.footnote-popover::-webkit-scrollbar-thumb,
.modal::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.annotations-list::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.footnote-popover::-webkit-scrollbar-thumb:hover,
.modal::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover,
.annotations-list::-webkit-scrollbar-thumb:hover {
  background: #a0aec0;
}

/* ===== Settings Page ===== */
.settings-page {
  max-width: 600px;
  margin: 0 auto;
}

.settings-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 16px 0 24px 0;
}

.settings-section {
  background: var(--color-bg-card);
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  margin-bottom: 20px;
}

.settings-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-primary);
  margin: 0 0 12px 0;
}

.settings-help {
  font-size: 14px;
  color: var(--color-text-secondary);
  line-height: 1.6;
  margin-bottom: 8px;
}

.settings-help a {
  color: var(--color-primary-lighter);
}

.settings-status {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  margin: 16px 0;
}

.settings-status-ok {
  background: #f0fff4;
  color: var(--color-success);
  border: 1px solid #c6f6d5;
}

.settings-status-warn {
  background: #fffbeb;
  color: #b7791f;
  border: 1px solid #fefcbf;
}

.settings-form {
  margin-top: 16px;
}

.settings-form .form-group {
  margin-bottom: 12px;
}

.settings-input-row {
  display: flex;
  gap: 8px;
}

.settings-input-row input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: monospace;
}

.settings-input-row input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(43, 76, 126, 0.15);
}

.settings-result {
  font-size: 13px;
  margin-left: 12px;
}

.settings-result.success { color: var(--color-success); }
.settings-result.error { color: var(--color-error); }

/* ---------------------------------------------------------------------------
   View History sidebar
   --------------------------------------------------------------------------- */
.view-history {
    max-height: 300px;
    overflow-y: auto;
}

/* ===== History Items ===== */
.history-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  color: var(--color-text);
  transition: background var(--transition-fast);
}

.history-item:hover {
  background: var(--color-primary-tint);
}

.history-item-content {
  flex: 1;
  min-width: 0;
}

.history-case-name {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-meta {
  font-size: 11px;
  color: var(--color-text-secondary);
  margin-top: 1px;
}

.history-time {
  font-size: 10px;
  color: var(--color-text-secondary);
  flex-shrink: 0;
  margin-top: 2px;
}

#history-filter {
    margin-bottom: 8px;
    font-size: 0.8rem;
    padding: 4px 8px;
}

/* ---------------------------------------------------------------------------
   Case Info Panel
   --------------------------------------------------------------------------- */
.case-info-row {
    margin-bottom: 8px;
}

.case-info-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-secondary);
    margin-bottom: 1px;
}

.case-info-value {
    font-size: 13px;
    color: var(--color-text);
    line-height: 1.4;
}

.case-info-link {
    font-size: 12px;
    color: var(--color-primary-lighter);
    text-decoration: none;
}

.case-info-link:hover {
    text-decoration: underline;
    color: var(--color-primary);
}

/* ===== Landing Page ===== */
.landing-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 0;
}

.landing-hero {
  text-align: center;
  margin-bottom: 40px;
}

.landing-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--color-primary);
  margin: 0 0 8px 0;
}

.landing-subtitle {
  font-size: 1rem;
  color: var(--color-text-secondary);
  margin: 0;
}

.landing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 32px;
}

.landing-section {
  background: var(--color-bg-card);
  border-radius: 8px;
  padding: 16px 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.landing-section-wide {
  grid-column: 1 / -1;
}

.landing-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-primary);
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid #edf2f7;
}

.landing-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.landing-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  color: var(--color-text);
  font-size: 13px;
  transition: background var(--transition-fast);
}

.landing-item:hover {
  background: var(--color-primary-tint);
}

.landing-item-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.landing-item-meta {
  font-size: 11px;
  color: var(--color-text-secondary);
  flex-shrink: 0;
  margin-left: 12px;
}

.recently-viewed-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.recent-case-card {
  flex-shrink: 0;
  width: 200px;
  padding: 12px;
  background: var(--color-bg);
  border: 1px solid #edf2f7;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  color: var(--color-text);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.recent-case-card:hover {
  border-color: var(--color-primary-lighter);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.recent-case-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}

.recent-case-cite {
  font-size: 11px;
  color: var(--color-text-secondary);
}

.landing-empty {
  text-align: center;
  padding: 16px;
  color: var(--color-text-secondary);
  font-size: 13px;
}

.setup-banner {
  background: var(--color-highlight-yellow);
  border: 1px solid #e8d374;
  border-radius: 6px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  font-size: 14px;
}

/* ===== Citation Modal ===== */
.citation-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-bottom: 2px solid #edf2f7;
}

.citation-tab {
  padding: 8px 20px;
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-ui);
  color: var(--color-text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.citation-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.citation-tab:hover {
  color: var(--color-primary);
}

.citation-format-group {
  margin-bottom: 14px;
}

.citation-format-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}

.citation-preview {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  padding: 10px 14px;
  background: var(--color-bg);
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
  user-select: all;
}

.citation-preview:hover {
  border-color: var(--color-primary-lighter);
  background: var(--color-primary-tint);
}

.citation-preview.copied {
  border-color: var(--color-success);
  background: #f0fff4;
}

.citation-preview em {
  font-style: italic;
}

.cite-missing {
  color: var(--color-error);
  font-weight: 700;
  font-size: 11px;
}

.citation-note-no-pin {
  font-size: 12px;
  color: var(--color-text-secondary);
  font-style: italic;
  margin: 12px 0 4px 0;
}

.citation-disclaimer {
  font-size: 11px;
  color: var(--color-text-secondary);
  margin: 8px 0 0 0;
  padding-top: 8px;
  border-top: 1px solid #edf2f7;
}

/* ---------------------------------------------------------------------------
   Folder case cards (used by folders.js buildFolderCaseCard)
   --------------------------------------------------------------------------- */
.result-card {
  padding: 12px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  margin-bottom: 8px;
  background: #fff;
}

.result-card:hover {
  border-color: #cbd5e0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.result-case-name {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 4px 0;
}

.result-meta {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
}

.meta-sep {
  margin: 0 2px;
  color: #a0aec0;
}

.result-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ---------------------------------------------------------------------------
   Error & status states
   --------------------------------------------------------------------------- */
.search-status-error {
  color: var(--color-error, #e53e3e);
  font-weight: 500;
}

.error-message {
  color: var(--color-error, #e53e3e);
  padding: 24px;
  text-align: center;
  font-size: 1rem;
}

/* ---------------------------------------------------------------------------
   Sidebar helpers
   --------------------------------------------------------------------------- */
.sidebar-collapse-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--color-text-secondary);
  padding: 2px 6px;
  border-radius: 4px;
}

.sidebar-collapse-btn:hover {
  background: #edf2f7;
}

/* ---------------------------------------------------------------------------
   Folder tree — system folder distinction
   --------------------------------------------------------------------------- */
.folder-tree-system {
  font-weight: 600;
}
