:root {
  --ink: #0e1116;
  --paper: #fafaf7;
  --rule: #d9d6cf;
  --accent: #2a4d8f;
  --accent-soft: #e8eef9;
  --muted: #5d6470;
  --hi: #ffe891;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
}
.wrap { max-width: 980px; margin: 0 auto; padding: 0 1.25rem; }

header {
  border-bottom: 1px solid var(--rule);
  padding: 2rem 0 1.25rem;
  background: #fff;
}
header h1 {
  font-family: "Iowan Old Style", Georgia, serif;
  font-size: 2.2rem;
  margin: 0;
  letter-spacing: -0.01em;
}
header .tag { margin: 0.35rem 0 0; color: var(--muted); font-size: 1rem; }

.intro { padding: 1.5rem 0 0.25rem; max-width: 760px; }
.intro p { margin: 0 0 0.85rem; }
.intro p:first-child { margin-top: 0; }

.searchbox { padding: 1rem 0 0.5rem; border-top: 1px solid var(--rule); margin-top: 1rem; }
#q {
  width: 100%;
  font-size: 1.15rem;
  padding: 0.85rem 1rem;
  border: 1.5px solid var(--rule);
  border-radius: 6px;
  background: #fff;
}
#q:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.addr-search {
  position: relative;
  margin-top: 0.4rem;
}
#addr {
  width: 100%;
  font-size: 0.95rem;
  padding: 0.55rem 0.85rem;
  border: 1.5px solid var(--rule);
  border-radius: 6px;
  background: #fff;
}
#addr:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.addr-suggestions {
  position: absolute;
  z-index: 10;
  left: 0; right: 0;
  top: 100%;
  background: #fff;
  border: 1px solid var(--rule);
  border-top: none;
  border-radius: 0 0 6px 6px;
  max-height: 280px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.06);
}
.addr-suggestion {
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  font-size: 0.92rem;
  border-bottom: 1px solid #ecebe6;
}
.addr-suggestion:last-child { border-bottom: none; }
.addr-suggestion:hover, .addr-suggestion[aria-selected="true"] {
  background: var(--accent-soft);
}
.addr-suggestion .label { color: var(--ink); }
.addr-suggestion .sub { color: var(--muted); font-size: 0.82rem; }

.addr-banner {
  background: #fff8e1;
  border: 1px solid #f0d990;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin: 1rem 0 0.5rem;
  font-size: 0.95rem;
}
.addr-banner strong { font-weight: 600; }
.addr-banner button {
  margin-left: 0.75rem;
  border: none;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.85rem;
  text-decoration: underline;
}

.filters {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}
.filters select {
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: #fff;
  font-size: 0.9rem;
}
.rss {
  margin-left: auto;
  font-size: 0.85rem;
  background: #fef0c7;
  padding: 0.35rem 0.6rem;
  border-radius: 4px;
  text-decoration: none;
  color: #7a4d00;
  border: 1px solid #f0d990;
}
.meta {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.hint {
  margin: 0.4rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}
.hint code {
  background: #f1efe7;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.82rem;
}

#results { margin-top: 1rem; }
.result {
  border-bottom: 1px solid var(--rule);
  padding: 0.9rem 0;
}
.result h3 {
  margin: 0 0 0.3rem;
  font-size: 1.05rem;
  font-weight: 600;
}
.result h3 a { color: var(--accent); text-decoration: none; }
.result h3 a:hover { text-decoration: underline; }
.result .badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.12rem 0.45rem;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-right: 0.35rem;
  vertical-align: 1px;
}
.result .meta-line {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0.15rem 0 0.4rem;
}
.result .meta-line span { margin-right: 0.85rem; }
.result .snippet {
  font-size: 0.92rem;
  color: #333;
  margin: 0;
}
.result mark { background: var(--hi); padding: 0 1px; }

.sources {
  border-top: 2px solid var(--rule);
  margin-top: 2.5rem;
  padding-top: 1.25rem;
}
.sources h2 { font-size: 1.1rem; margin: 0 0 0.6rem; }
.coverage-intro {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0 0 1rem;
}
#source-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.7rem 1.25rem;
  font-size: 0.9rem;
}
#source-list li { line-height: 1.35; }
#source-list .source-row { display: flex; justify-content: space-between; gap: 0.5rem; }
#source-list .source-name { font-weight: 500; }
#source-list .count { color: var(--muted); font-variant-numeric: tabular-nums; }
#source-list .source-coverage { color: var(--muted); font-size: 0.78rem; }
.fineprint { font-size: 0.82rem; color: var(--muted); margin-top: 1rem; }

.loading-bar {
  position: relative;
  height: 4px;
  background: #ecebe6;
  border-radius: 2px;
  margin: 1rem 0;
  overflow: hidden;
}
.loading-bar-fill {
  position: absolute;
  inset: 0 100% 0 0;
  background: var(--accent);
  transition: right 0.3s ease;
}
.loading-bar-label {
  position: absolute;
  inset: 6px 0 auto 0;
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
  padding-top: 4px;
  display: block;
}

#pager {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0 2rem;
  justify-content: center;
}
#pager button {
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--rule);
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
}
#pager button:disabled { opacity: 0.4; cursor: default; }

footer {
  border-top: 1px solid var(--rule);
  margin-top: 3rem;
  padding: 1.5rem 0;
  background: #fff;
  font-size: 0.85rem;
  color: var(--muted);
}

@media (max-width: 600px) {
  header h1 { font-size: 1.6rem; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters select, .rss { width: 100%; text-align: center; }
  .rss { margin-left: 0; }
}
