body { font-family: -apple-system, system-ui, sans-serif; max-width: 960px; margin: 2rem auto; padding: 0 1rem; color: #222; }
header { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid #ddd; padding-bottom: 0.5rem; margin-bottom: 1.5rem; }
header .host { font-size: 0.8rem; color: #888; font-weight: normal; }
nav a { margin-left: 1rem; text-decoration: none; color: #06c; }
section { margin-bottom: 2.5rem; }
h2 { font-size: 1.1rem; color: #444; border-bottom: 1px solid #eee; padding-bottom: 0.25rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.3rem 0.5rem; border-bottom: 1px solid #eee; }
input[type=text] { width: 60%; padding: 0.4rem; }
button { padding: 0.4rem 0.9rem; margin-left: 0.5rem; }
#log-pane { background: #111; color: #0f0; padding: 1rem; height: 260px; overflow-y: auto; font-size: 0.8rem; white-space: pre-wrap; }
.muted { color: #888; }
.error { color: #c00; }

.status-line { display: flex; align-items: center; gap: 0.5rem; }
.spinner {
  display: inline-block; width: 0.9rem; height: 0.9rem; flex: none;
  border: 2px solid #ddd; border-top-color: #06c; border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

select { padding: 0.4rem; margin-left: 0.5rem; }

.progress-bar { display: inline-block; width: 140px; height: 10px; background: #eee; border-radius: 5px; overflow: hidden; vertical-align: middle; }
.progress-bar-fill { height: 100%; background: #2a8f2a; width: 0%; transition: width 0.3s ease; }
.progress-bar-fill-error { background: #c00; }
.progress-label { font-size: 0.8rem; color: #666; margin-left: 0.5rem; }
.live-progress { display: flex; align-items: center; margin-bottom: 0.5rem; }
.live-progress .progress-bar { width: 240px; }

.pager { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.5rem; font-size: 0.85rem; }
.pager button { padding: 0.25rem 0.6rem; margin-left: 0; }
.pager button:disabled { opacity: 0.4; cursor: default; }
button.danger { background: #fdecea; border: 1px solid #e0a5a0; color: #a12; }
button.danger:hover { background: #f9d3ce; }

#db-section, #llm-section, #models-section { margin-bottom: 2.5rem; }
#settings-db, #settings-llm, #settings-models form { display: flex; flex-direction: column; gap: 0.7rem; max-width: 480px; }
#settings-llm label, #settings-models label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.85rem; color: #555; }
#settings-llm input, #settings-llm select, #settings-models select { padding: 0.4rem; margin-left: 0; }
.btn-row { display: flex; gap: 0.6rem; margin-top: 0.3rem; }
.banner { background: #eef6ff; border: 1px solid #b8dcff; padding: 0.5rem 0.8rem; border-radius: 4px; }
.ok { color: #2a8f2a; }
table.compact { width: auto; margin-bottom: 0.6rem; }
table.compact td { padding: 0.15rem 1rem 0.15rem 0; border: none; }

.snippet { background: #1a1a1a; color: #e8e8e8; padding: 0.8rem 1rem; border-radius: 5px; overflow-x: auto; font-size: 0.85rem; line-height: 1.4; }

.tab-btn { background: none; border: none; padding: 0.3rem 0; margin: 0 1rem 0 0; font-size: 1rem; color: #06c; cursor: pointer; border-bottom: 2px solid transparent; }
.tab-btn:hover { color: #049; }
.tab-btn.active { color: #222; border-bottom-color: #06c; font-weight: 600; }
nav { display: flex; align-items: baseline; flex-wrap: wrap; }

.markdown-body { font-size: 0.95rem; line-height: 1.55; }
.markdown-body p { margin: 0 0 0.8rem; }
.markdown-body ul, .markdown-body ol { margin: 0 0 0.8rem; padding-left: 1.4rem; }
.markdown-body li { margin-bottom: 0.3rem; }
.markdown-body code { background: #f2f2f2; padding: 0.1rem 0.3rem; border-radius: 3px; font-size: 0.85em; }
.markdown-body pre code { display: block; padding: 0.6rem; overflow-x: auto; }
.citation-ref { text-decoration: none; color: #06c; font-weight: 600; }
.citation-ref:hover { text-decoration: underline; }

.citation-list { list-style: none; padding: 0; margin: 0.5rem 0 0; display: flex; flex-direction: column; gap: 0.4rem; }
.citation-item { display: flex; align-items: baseline; gap: 0.6rem; background: #f7f8fa; border: 1px solid #eaeaea; border-radius: 6px; padding: 0.45rem 0.7rem; scroll-margin-top: 1rem; }
.citation-item:target { background: #eef6ff; border-color: #b8dcff; }
.citation-badge { flex: none; background: #06c; color: #fff; font-size: 0.75rem; font-weight: 600; border-radius: 50%; width: 1.4rem; height: 1.4rem; display: flex; align-items: center; justify-content: center; }
.citation-body { flex: 1; display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.citation-title { font-size: 0.85rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.citation-meta { font-size: 0.75rem; color: #888; }
.citation-score { flex: none; font-size: 0.75rem; color: #999; font-variant-numeric: tabular-nums; }

.search-hit-card { background: #fff; border: 1px solid #eaeaea; border-radius: 6px; padding: 0.6rem 0.8rem; margin-bottom: 0.6rem; }
.search-hit-meta { display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.4rem; }
.search-hit-meta .citation-title { white-space: normal; flex: 1 1 auto; }
.search-hit-content { font-size: 0.9rem; }
.search-hit-content > *:last-child { margin-bottom: 0; }

/* ---- mobile (phones/small tablets) ---- */
@media (max-width: 640px) {
  body { margin: 0.75rem auto; padding: 0 0.75rem; }
  header { flex-direction: column; align-items: flex-start; gap: 0.4rem; }
  nav { gap: 0.4rem 0.8rem; }
  nav a { margin-left: 0; }
  .tab-btn { margin-right: 0.6rem; }

  input[type=text] { width: 100%; box-sizing: border-box; margin-bottom: 0.5rem; }
  button { margin-left: 0; }
  .btn-row { flex-wrap: wrap; }

  /* Wide data tables scroll horizontally as a block instead of squeezing columns. */
  table:not(.compact) { display: block; overflow-x: auto; white-space: nowrap; }

  #log-pane { height: 180px; }
  .progress-bar, .live-progress .progress-bar { width: 100px; }

  .citation-item { flex-wrap: wrap; }
  .search-hit-meta { gap: 0.4rem; }
}
