:root {
  --bg: #f1f2f4;
  --surface: #ffffff;
  --fg: #111820;
  --meta: #52525b;
  --muted: #a1a1aa;
  --link: #1c4fb4;
  --link-hover: #153a88;
  --border: #d8d8dc;
  --card-accent: #c5d8fa;
  --card-accent-hover: #1c4fb4;
  --hover: #f4f8ff;
  --error: #b91c1c;
  --focus: #3b82f6;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ── Top bar ──────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 32px;
  height: 56px;
}

.topbar-search-wrap {
  flex: 1;
  max-width: 420px;
  transition: max-width 200ms ease;
}

/* on landing, topbar search is hidden — hero has its own */
.landing .topbar-search-wrap {
  display: none;
}

.topbar-search-wrap .search-input {
  font-size: 0.88em;
  padding: 8px 14px;
  border-radius: 8px;
  box-shadow: none;
}

.topbar-brand-link {
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
  line-height: 1;
}

.topbar-brand {
  font-size: 1.05em;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--fg);
  user-select: none;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.topbar-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  flex-shrink: 0;
  margin: 0 6px;
}

.topbar-about {
  font-size: 0.85em;
  color: var(--meta);
  text-decoration: none;
  font-weight: 500;
  flex-shrink: 0;
  padding: 4px 6px;
}

.topbar-about:hover { color: var(--fg); }

/* ── Tab buttons ──────────────────────────────────────────── */

.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 6px 12px;
  font-size: 0.88em;
  font-family: inherit;
  color: var(--meta);
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  text-decoration: none;
  transition: color 120ms ease;
}

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

.tab.active {
  color: var(--fg);
  font-weight: 600;
  border-bottom-color: var(--fg);
}

/* ── Page body ────────────────────────────────────────────── */

.app {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 32px 40px;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 56px - 49px); /* subtract topbar + site-footer */
}

/* ── Hero ─────────────────────────────────────────────────── */

.hero {
  display: none;
  padding: 56px 32px 40px;
  text-align: center;
}

.landing .hero {
  display: block;
}

.hero-content {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero-eyebrow {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 0 0 10px;
  font-weight: 600;
}

.hero-wordmark {
  font-size: 2em;
  font-weight: 800;
  letter-spacing: -0.05em;
  color: var(--fg);
  margin: 0 0 10px;
  line-height: 1;
}

.hero-sub {
  font-size: 1.05em;
  color: var(--fg);
  margin: 0 0 16px;
  max-width: 520px;
  line-height: 1.5;
}

.hero-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}

.hero-search-wrap {
  width: 100%;
  max-width: 560px;
  margin-bottom: 14px;
}

.hero-search-input {
  font-size: 1.05em;
  padding: 15px 22px;
  border-radius: 28px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07), 0 1px 4px rgba(0,0,0,0.05);
}

.hero-search-input:focus {
  box-shadow: 0 2px 12px rgba(0,0,0,0.07), 0 0 0 3px rgba(59,130,246,0.14);
}

.stats-strip {
  font-size: 0.82rem;
  color: var(--meta);
  margin: 0;
}

/* ── Section label ────────────────────────────────────────── */

.section-label {
  font-size: 0.71rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0 0 12px;
  font-weight: 600;
}

/* ── Chip container ───────────────────────────────────────── */

.chip-container {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 18px;
}

/* ── Main content ─────────────────────────────────────────── */

.main { flex: 1; }

.status {
  color: var(--meta);
  text-align: center;
  margin: 32px 0;
  font-size: 0.92em;
}

.error {
  color: var(--error);
  margin: 24px 0;
  font-size: 0.92em;
}

/* ── Search ───────────────────────────────────────────────── */

.search-wrap {
  position: relative;
  width: 100%;
}

.search-form { width: 100%; }

.search-input {
  width: 100%;
  padding: 14px 18px;
  font-size: 1.05em;
  font-family: inherit;
  color: var(--fg);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  outline: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.search-input:focus {
  border-color: var(--focus);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 0 0 3px rgba(59,130,246,0.14);
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.09);
  list-style: none;
  margin: 0;
  padding: 4px 0;
  z-index: 200;
  max-height: 340px;
  overflow-y: auto;
}

.search-dropdown li a {
  display: block;
  padding: 10px 16px;
  text-decoration: none;
  color: var(--fg);
  transition: background 80ms ease;
}

.search-dropdown li a:hover,
.search-dropdown li.dd-active a {
  background: var(--hover);
}

.dd-title {
  display: block;
  font-size: 0.92em;
  font-weight: 500;
  line-height: 1.3;
  color: var(--fg);
}

.dd-meta {
  display: block;
  font-size: 0.76em;
  color: var(--meta);
  margin-top: 1px;
}

.chip {
  border: 1px solid #d1d5db;
  background: var(--surface);
  border-radius: 20px;
  padding: 4px 13px;
  cursor: pointer;
  font-size: 0.81rem;
  font-family: inherit;
  color: var(--meta);
  line-height: 1.5;
  transition: background 100ms ease, border-color 100ms ease, color 100ms ease;
}

.chip:hover {
  border-color: #93c5fd;
  background: #eff6ff;
  color: var(--link);
}

/* ── Result cards ─────────────────────────────────────────── */

.results {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Browse grid: Top and Recent tabs */
.results--grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.results--grid .result {
  display: flex;
  flex-direction: column;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  border-left: 1px solid var(--border); /* override list accent */
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: box-shadow 140ms ease, border-color 140ms ease;
}

.results--grid .result:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  border-color: #c5d8fa;
}

.results--grid .result-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.results--grid .card-actions {
  margin-top: auto;
  padding-top: 10px;
}

/* Search result list: single column, ranked */
.results--list .result {
  border-left: 3px solid var(--card-accent);
  border-radius: 0 6px 6px 0;
  background: var(--surface);
  transition: border-left-color 140ms ease, background 140ms ease;
}

.results--list .result:hover {
  border-left-color: var(--card-accent-hover);
  background: var(--hover);
}

.result {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 16px 15px 19px;
}

.results--grid .result {
  /* grid cards are column-stacked, override horizontal flex */
  flex-direction: column;
  gap: 0;
  padding: 16px;
  align-items: stretch;
  justify-content: flex-start;
}

.result-main { min-width: 0; flex: 1; }

.result-source {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 5px;
}

.result-title {
  display: block;
  font-size: 1.02em;
  font-weight: 600;
  color: var(--link);
  text-decoration: none;
  word-break: break-word;
  line-height: 1.35;
  margin-bottom: 4px;
}

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

.result-breadcrumb {
  font-size: 0.76em;
  color: var(--muted);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-meta-line {
  display: flex;
  align-items: baseline;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.result-company {
  color: var(--meta);
  font-size: 0.84em;
  font-weight: 500;
}

.result-date-sep {
  color: var(--muted);
  font-size: 0.82em;
}

.result-date {
  color: var(--muted);
  font-size: 0.82em;
}

.result-score {
  color: var(--muted);
  font-size: 0.76em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  padding-top: 4px;
}

.result-tldr {
  margin: 5px 0 0;
  font-size: 0.88em;
  color: var(--meta);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.5;
}

.result-tldr strong {
  font-weight: 600;
  color: var(--fg);
}

.explain-toggle {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 10px;
}

.explain-toggle a {
  color: var(--muted);
  text-decoration: none;
}

.explain-toggle a:hover { text-decoration: underline; }

.result-explain {
  margin-top: 6px;
  padding-left: 4px;
  font-size: 0.76rem;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.result-explain summary {
  cursor: pointer;
  user-select: none;
  color: var(--muted);
}

.result-explain span {
  display: block;
  margin-top: 2px;
  padding-left: 12px;
}

/* ── Card actions — hover reveal ──────────────────────────── */

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.result:hover .card-actions,
.result:focus-within .card-actions {
  opacity: 1;
  pointer-events: auto;
}

/* always show on touch devices */
@media (hover: none) {
  .card-actions {
    opacity: 1;
    pointer-events: auto;
  }
}

.footer {
  margin-top: 20px;
  color: var(--meta);
  font-size: 0.82em;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ── More like this ───────────────────────────────────────── */

.mlt-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 0.77em;
  color: var(--meta);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 100ms ease, color 100ms ease;
}

.mlt-btn:hover { border-color: var(--meta); color: var(--fg); }

.back-btn {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 12px;
  background: var(--surface);
  font-size: 0.84em;
  color: var(--meta);
  cursor: pointer;
  font-family: inherit;
  margin-bottom: 20px;
  transition: color 100ms ease, border-color 100ms ease;
  display: inline-block;
}
.back-btn:hover { color: var(--fg); border-color: var(--meta); }

.mlt-diverse { margin-top: 6px; }

.neighbor-panel {
  position: relative;
  margin-top: 10px;
  padding: 11px 14px 11px 14px;
  background: #f5f8ff;
  border-left: 3px solid var(--card-accent);
  border-radius: 0 4px 4px 0;
}

.neighbor-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  font-size: 1rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 3px;
}
.neighbor-close:hover { color: var(--fg); background: var(--border); }

.neighbor-heading {
  font-size: 0.71em;
  color: var(--meta);
  margin-bottom: 8px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.neighbor-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.neighbor-list a {
  font-size: 0.87em;
  color: var(--link);
  text-decoration: none;
}

.neighbor-list a:hover { text-decoration: underline; }

.neighbor-company {
  font-size: 0.81em;
  color: var(--muted);
}

.neighbor-meta {
  font-size: 0.78em;
  color: var(--muted);
}

.neighbor-tldr {
  font-size: 0.82em;
  color: var(--meta);
  margin: 3px 0 0;
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ── Explore / cluster grid ───────────────────────────────── */

.cluster-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.cluster-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  transition: background 100ms ease, box-shadow 100ms ease;
  background: var(--surface);
}

.cluster-card:hover {
  background: var(--hover);
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

.cluster-label {
  font-weight: 600;
  font-size: 0.92em;
  margin: 0 0 3px;
  text-transform: capitalize;
}

.cluster-count {
  font-size: 0.76em;
  color: var(--muted);
  margin: 0 0 10px;
}

.cluster-posts {
  list-style: none;
  margin: 0;
  padding: 0;
}

.cluster-posts li {
  font-size: 0.83em;
  margin-bottom: 5px;
  line-height: 1.35;
}

.cluster-posts a {
  color: var(--link);
  text-decoration: none;
}

.cluster-posts a:hover { text-decoration: underline; color: var(--link-hover); }

.cluster-posts .post-company {
  color: var(--meta);
  font-size: 0.9em;
}

/* ── Explore breadcrumb ───────────────────────────────────── */

.explore-breadcrumb {
  font-size: 0.71rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 8px;
}

/* ── About page ───────────────────────────────────────────── */

.about-app {
  padding-top: 40px;
}

.about-hero {
  margin-bottom: 36px;
}

.about-title {
  font-size: 1.65em;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 10px;
  line-height: 1.2;
}

.about-subtitle {
  font-size: 0.97em;
  color: var(--meta);
  margin: 0;
  max-width: 520px;
  line-height: 1.6;
}

.about-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 44px;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-num {
  font-size: 1.6em;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

.metric-label {
  font-size: 0.74em;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

.about-section {
  margin-bottom: 40px;
}

.about-section-title {
  font-size: 0.71rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  margin: 0 0 16px;
}

.pipeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.pipeline-step {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.pipeline-step:last-child { border-bottom: none; }

.pipeline-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--fg);
  color: var(--surface);
  font-size: 0.75em;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.pipeline-body strong {
  display: block;
  font-size: 0.95em;
  margin-bottom: 4px;
}

.pipeline-body p {
  font-size: 0.88em;
  color: var(--meta);
  margin: 0;
  line-height: 1.55;
}

.tech-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tech-tag {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 11px;
  font-size: 0.82em;
  color: var(--meta);
  font-weight: 500;
}

.about-cols {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 44px;
  align-items: start;
}

.about-subtabs {
  display: flex;
  gap: 2px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.about-subtab {
  background: none;
  border: none;
  padding: 7px 14px;
  font-size: 0.88em;
  font-family: inherit;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 120ms ease, border-color 120ms ease;
}

.about-subtab:hover { color: var(--fg); }

.about-subtab.active {
  color: var(--fg);
  font-weight: 600;
  border-bottom-color: var(--fg);
}

/* ── Site footer ──────────────────────────────────────────── */

.site-footer {
  padding: 16px 32px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--muted);
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
}

.ranking-info {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.02em;
}

.about-link {
  color: var(--muted);
  text-decoration: none;
}

.about-link:hover {
  color: var(--meta);
  text-decoration: underline;
}

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 860px) {
  .cluster-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .results--grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .about-metrics { grid-template-columns: repeat(2, 1fr); }
  .about-title { font-size: 1.3em; }
  .about-cols { grid-template-columns: 1fr; }
}

@media (max-width: 540px) {
  .topbar-inner { padding: 0 12px; gap: 8px; }
  .topbar-search-wrap { max-width: none; }
  .landing .topbar-search-wrap { max-width: none; }
  .app { padding: 16px 16px 28px; }
  .tab { padding: 5px 7px; font-size: 0.8em; }
  .result { flex-direction: column; gap: 4px; }
  .site-footer { padding: 16px; flex-direction: column; gap: 8px; align-items: flex-start; }
  .hero { padding: 40px 20px 32px; }
  .hero-wordmark { font-size: 1.7em; }
}

@media (max-width: 480px) {
  .cluster-grid { grid-template-columns: 1fr; }
}
