/* -- Filter bar -- */
.filter-bar {
  margin-top: 12px;
  display: flex;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-label {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(0, 0, 0, 0.6);
  white-space: nowrap;
}

.filter-dates {
  display: flex;
  align-items: center;
  gap: 4px;
}

.filter-dates input[type="date"] {
  padding: 4px 8px;
  font-size: 0.88rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
}

.filter-date-sep {
  color: rgba(0, 0, 0, 0.4);
  font-size: 0.9rem;
}

.filter-checkboxes {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-check {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 0.88rem;
  font-weight: 400;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}

.filter-check input[type="checkbox"] {
  accent-color: var(--accent);
  margin: 0;
  cursor: pointer;
}

/* -- Search layout -- */
.search-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 16px;
  align-items: start;
}

.chat-panel,
.citation-panel,
.results-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.results-panel {
  grid-column: 1 / -1;
  min-height: 48vh;
}

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  background: #f6f8fa;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  min-height: 360px;
  max-height: 560px;
}

.chat-empty,
.placeholder {
  color: rgba(0, 0, 0, 0.56);
  font-size: 0.95rem;
}

.chat-message {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  line-height: 1.45;
}

.chat-message.user {
  background: #16335c;
  color: #f4f7fb;
  margin-left: 12%;
  white-space: pre-wrap;
}

.chat-message.assistant {
  background: #f1f3f6;
  color: #1f1f1f;
  border: 1px solid rgba(0, 0, 0, 0.08);
  margin-right: 8%;
  max-width: 920px;
}

.answer-markdown {
  font-size: 0.96rem;
}

.answer-markdown h3,
.answer-markdown h4 {
  margin: 4px 0 8px;
  line-height: 1.25;
  color: #172235;
}

.answer-markdown h3 {
  font-size: 1.08rem;
}

.answer-markdown h4 {
  font-size: 1rem;
}

.answer-paragraph {
  margin: 0 0 12px;
}

.answer-paragraph:last-child {
  margin-bottom: 0;
}

.answer-paragraph.uncited {
  border-left: 3px solid #aab2bd;
  padding-left: 10px;
}

.answer-markdown ul,
.answer-markdown ol {
  margin: 0 0 12px 22px;
  padding: 0;
}

.answer-markdown li {
  margin: 4px 0;
}

.answer-markdown blockquote {
  margin: 0 0 12px;
  padding: 8px 12px;
  border-left: 3px solid #aab2bd;
  background: rgba(255, 255, 255, 0.45);
}

.answer-markdown code {
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.07);
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.9em;
}

.answer-markdown pre {
  overflow-x: auto;
  margin: 0 0 12px;
  padding: 10px;
  border-radius: 6px;
  background: #171717;
  color: #f3f3f3;
}

.answer-markdown pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.answer-markdown a {
  color: #214f83;
}

.chat-stats {
  margin: -6px 0 12px 0;
  padding: 6px 10px;
  background: #1a1a2e;
  border: 1px solid #2a2a4a;
  border-radius: 6px;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 11px;
  line-height: 1.6;
  color: #a0a8c0;
  margin-right: 8%;
}

.chat-stats .stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  align-items: baseline;
}

.chat-stats .stat-label {
  color: #7eb8da;
  font-weight: 600;
  margin-right: 4px;
}

.chat-stats .stat-val {
  color: #e0d8c8;
  font-weight: 600;
}

.chat-stats .stat-dim {
  color: #6a7080;
}

.chat-form {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-form textarea {
  width: 100%;
  resize: vertical;
  border: 1.5px solid var(--border-strong);
  border-radius: 8px;
  padding: 10px;
  font-family: var(--ui-font);
  font-size: 0.98rem;
}

.chat-form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-status {
  font-size: 0.88rem;
  color: rgba(0, 0, 0, 0.66);
}

.results-content {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  grid-template-rows: auto 1fr;
  gap: 10px;
  padding: 10px;
  flex: 1;
  overflow: hidden;
}

.passes-panel {
  grid-column: 1 / -1;
  background: #f6f8fa;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  padding: 10px;
  max-height: 260px;
  overflow-y: auto;
}

.subhead {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(0, 0, 0, 0.7);
  margin-bottom: 8px;
}

.pass-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px dashed rgba(0, 0, 0, 0.14);
  font-size: 0.9rem;
}

.pass-item:first-child {
  border-top: none;
}

.pass-tag {
  font-weight: 700;
}

.pass-status {
  text-transform: lowercase;
  font-weight: 700;
}

.pass-status.partial {
  color: #7a5a00;
}

.pass-status.failed {
  color: #8f1212;
}

.pass-status.final {
  color: #155d28;
}

.agent-progress {
  padding: 8px 0;
}

.agent-progress-head {
  font-weight: 700;
  color: #16335c;
}

.agent-progress-detail {
  margin-top: 4px;
  color: rgba(0, 0, 0, 0.62);
  font-size: 0.88rem;
}

.agent-error-card {
  border: 1px solid rgba(143, 18, 18, 0.28);
  background: #fff7f5;
  border-radius: 8px;
  padding: 10px 12px;
  color: #5b1712;
}

.agent-progress-bar {
  height: 4px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(22, 51, 92, 0.14);
}

.agent-progress-bar span {
  display: block;
  width: 36%;
  height: 100%;
  border-radius: inherit;
  background: #16335c;
  animation: agent-progress-slide 1.4s ease-in-out infinite;
}

@keyframes agent-progress-slide {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(280%);
  }
}

.trail-item {
  border-top: 1px dashed rgba(0, 0, 0, 0.14);
  padding: 7px 0;
  font-size: 0.9rem;
}

.trail-item:first-child {
  border-top: none;
}

.trail-item summary {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  cursor: pointer;
  align-items: center;
}

.trail-args {
  margin: 8px 0;
  padding: 6px 8px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 6px;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.trail-evidence {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 4px 0;
  color: rgba(0, 0, 0, 0.76);
}

.articles-panel,
.detail-panel {
  min-height: 0;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  padding: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.articles-list {
  overflow-y: auto;
  min-height: 0;
}

.article-item {
  padding: 10px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  background: #fff;
}

.article-item:hover {
  border-color: rgba(16, 48, 80, 0.45);
}

.article-item.active {
  border-color: #16335c;
  box-shadow: inset 0 0 0 1px #16335c;
}

.article-rank {
  display: inline-block;
  min-width: 2.2rem;
  font-weight: 700;
  color: #16335c;
}

.article-title {
  font-weight: 700;
  margin: 4px 0;
}

.article-meta {
  font-size: 0.83rem;
  color: rgba(0, 0, 0, 0.66);
}

.article-snippet {
  margin-top: 6px;
  font-size: 0.9rem;
  color: rgba(0, 0, 0, 0.8);
}

.article-detail {
  overflow-y: auto;
  min-height: 0;
  white-space: pre-wrap;
}

.article-fulltext {
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.citation-chip {
  display: inline-flex;
  align-items: center;
  background: #eef1f5;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 999px;
  padding: 2px 8px;
  margin: 0 6px 6px 0;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  line-height: 1.35;
  text-align: left;
  white-space: nowrap;
}

.citation-chip.cited {
  background: #dfeadd;
  border-color: rgba(21, 93, 40, 0.26);
}

.citation-chip.available {
  background: #eef1f5;
}

.citation-chip.unresolved {
  background: #f2dddd;
  border-color: rgba(143, 18, 18, 0.24);
}

.citation-chip.active {
  border-color: #16335c;
  box-shadow: 0 0 0 2px rgba(22, 51, 92, 0.18);
}

.citation-jump {
  text-decoration: none;
}

.citation-inspector {
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  background: #ffffff;
  max-height: 280px;
  overflow-y: auto;
  padding: 10px;
}

.citation-inspector-card,
.citation-inspector-empty {
  border: 1px solid rgba(22, 51, 92, 0.14);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.citation-inspector-empty {
  color: rgba(0, 0, 0, 0.7);
}

.citation-rail {
  overflow-y: auto;
  min-height: 0;
  padding: 10px;
  max-height: 620px;
}

.citation-card {
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  padding: 10px 0;
}

.citation-card.active {
  margin: 0 -8px;
  padding: 10px 8px;
  border: 1px solid rgba(22, 51, 92, 0.34);
  border-radius: 8px;
  background: #f4f8fd;
  box-shadow: inset 3px 0 0 #16335c;
}

.citation-card:first-child {
  padding-top: 0;
}

.citation-card.unresolved {
  color: #6f1717;
}

.source-title {
  font-weight: 700;
  line-height: 1.25;
}

.citation-card-chips {
  margin-top: 8px;
}

.source-state {
  margin-top: 2px;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  color: rgba(0, 0, 0, 0.58);
}

.source-excerpt {
  margin-top: 8px;
  font-size: 0.88rem;
  line-height: 1.4;
  color: rgba(0, 0, 0, 0.78);
}

.source-why {
  margin-top: 8px;
  font-size: 0.78rem;
  color: rgba(0, 0, 0, 0.58);
  line-height: 1.35;
}

.source-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.source-actions .ghost-link {
  background: transparent;
  cursor: pointer;
  font: inherit;
}

.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.button-row .btn {
  white-space: nowrap;
}

@media (max-width: 1080px) {
  .search-layout {
    grid-template-columns: 1fr;
  }

  .chat-panel,
  .citation-panel,
  .results-panel {
    min-height: 0;
  }

  .results-panel {
    grid-column: auto;
  }

  .chat-body {
    min-height: 0;
    max-height: none;
  }

  .chat-message.user,
  .chat-message.assistant,
  .chat-stats {
    margin-left: 0;
    margin-right: 0;
  }

  .button-row {
    width: 100%;
  }

  .button-row .btn {
    flex: 1 1 135px;
  }

  .filter-group {
    align-items: flex-start;
    flex-direction: column;
  }

  .filter-dates {
    flex-wrap: wrap;
  }

  .filter-dates input[type="date"] {
    max-width: 146px;
  }

  .results-content {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  .articles-panel,
  .detail-panel {
    min-height: 280px;
  }
}

/* Example query chips shown in the empty chat state. */
.example-chips {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
  align-items: flex-start;
}

.example-chip {
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--accent, #16335c);
  background: var(--panel-bg, #ffffff);
  border: 1px solid var(--border, #cdd3db);
  border-radius: 16px;
  padding: 6px 14px;
  cursor: pointer;
  text-align: left;
}

.example-chip:hover {
  border-color: var(--accent, #16335c);
  background: rgba(138, 75, 45, 0.06);
}

/* Publication badges on search results (multi-paper corpus). */
.pub-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1;
  padding: 3px 7px;
  margin-right: 6px;
  border-radius: 10px;
  vertical-align: middle;
  white-space: nowrap;
  color: #fff;
  background: #6b7280; /* default slate */
}
.pub-badge.pub-the-liberator { background: #16335c; }
.pub-badge.pub-daily-national-intelligencer { background: #1f6feb; }
.pub-badge.pub-phenix-gazette { background: #6f42c1; }
.pub-badge.pub-lynchburg-virginian { background: #198754; }
.pub-badge.pub-richmond-enquirer { background: #b8860b; }
.pub-badge.pub-constitutional-whig { background: #b02a37; }

/* -- Era switch (Antebellum / Revolution corpus toggle) -- */
:root { --era-accent: var(--accent, #16335c); }

.era-switch {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin: 0 0 10px 0;
  background: var(--paper-dark, #ede4d6);
  border: 1px solid var(--border, #cdd3db);
  border-radius: 999px;
}

.era-switch button {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  padding: 6px 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted, #6b5f4a);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.15;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.era-switch button .era-opt-years {
  font-size: 0.72rem;
  font-weight: 500;
  opacity: 0.8;
  letter-spacing: 0.02em;
}

.era-switch button:hover {
  color: var(--ink, #1e1b16);
}

.era-switch button.active {
  background: var(--era-accent);
  color: #fff;
  box-shadow: 0 2px 6px rgba(19, 17, 12, 0.18);
}

.era-switch button.active .era-opt-years { opacity: 0.9; }

.era-badge {
  display: inline-block;
  vertical-align: middle;
  margin-left: 10px;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--era-accent);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* Era-tinted accents on the search hero and active example chips. */
.hero { border-top: 3px solid var(--era-accent); }
.example-chip:hover { border-color: var(--era-accent); color: var(--era-accent); }
.ghost-link.active { border-color: var(--era-accent); color: var(--era-accent); }
