/* ============================================================
   LeadFlow — "Signal Terminal" theme
   Deep warm charcoal · lime signal accent · editorial serif
   ============================================================ */

:root {
  --bg: #0c0c0e;
  --bg-2: #121216;
  --panel: #16161b;
  --panel-2: #1c1c22;
  --line: #26262e;
  --line-soft: #1e1e25;
  --ink: #f3f1ea;
  --ink-dim: #a5a29a;
  --ink-faint: #6d6a63;
  --signal: #c8f24a;      /* lime — "signal detected" */
  --signal-deep: #a6d02f;
  --amber: #f4a950;
  --rose: #ff6b6b;
  --blue: #5aa9ff;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.7);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Hanken Grotesk", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 78% -10%, rgba(200, 242, 74, 0.08), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, rgba(90, 169, 255, 0.05), transparent 55%),
    var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* film grain overlay */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: var(--signal); color: #10130a; }

a { color: inherit; }

/* ---------------- Topbar ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px clamp(18px, 5vw, 56px);
  background: rgba(12, 12, 14, 0.72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand__mark {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 9px;
  color: #10130a;
  background: var(--signal);
  box-shadow: 0 0 0 1px rgba(200, 242, 74, 0.4), 0 8px 22px -8px rgba(200, 242, 74, 0.6);
}
.brand__name { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.brand__name em { font-style: normal; color: var(--signal); }
.topbar__right { display: flex; align-items: center; gap: 16px; }
.status-pills { display: flex; gap: 8px; }
.pill {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 100px;
  border: 1px solid var(--line);
  color: var(--ink-dim);
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-faint); display: inline-block; }
.pill.ok i { background: var(--signal); box-shadow: 0 0 8px var(--signal); }
.pill.bad i { background: var(--rose); box-shadow: 0 0 8px var(--rose); }
.ghost-btn {
  font-family: var(--font-mono);
  font-size: 12px;
  text-decoration: none;
  color: var(--ink-dim);
  border: 1px solid var(--line);
  padding: 8px 12px;
  border-radius: 100px;
  transition: 0.2s;
}
.ghost-btn:hover { color: var(--ink); border-color: var(--signal); }

/* ---------------- Hero ---------------- */
.hero {
  position: relative;
  z-index: 2;
  max-width: 1120px;
  margin: 0 auto;
  padding: clamp(40px, 7vw, 84px) clamp(18px, 5vw, 56px) 26px;
}
.hero__eyebrow {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--font-mono);
  font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-dim);
  border: 1px solid var(--line);
  padding: 7px 13px; border-radius: 100px;
  background: var(--panel);
}
.hero__eyebrow .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 0 0 rgba(200, 242, 74, 0.6);
  animation: ping 2.2s infinite;
}
@keyframes ping {
  0% { box-shadow: 0 0 0 0 rgba(200, 242, 74, 0.55); }
  70% { box-shadow: 0 0 0 10px rgba(200, 242, 74, 0); }
  100% { box-shadow: 0 0 0 0 rgba(200, 242, 74, 0); }
}
.hero__title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(38px, 7vw, 76px);
  line-height: 0.98;
  letter-spacing: -0.025em;
  margin: 22px 0 18px;
}
.hero__title em { font-style: italic; color: var(--signal); }
.hero__sub {
  max-width: 560px;
  color: var(--ink-dim);
  font-size: clamp(15px, 2vw, 18px);
  line-height: 1.55;
  margin: 0;
}

/* ---------------- Search ---------------- */
.search {
  position: relative;
  z-index: 2;
  max-width: 1120px;
  margin: 34px auto 0;
  padding: 0 clamp(18px, 5vw, 56px);
}
.search__row { display: flex; gap: 12px; }
.search__field {
  flex: 1;
  display: flex; align-items: center; gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 18px;
  transition: 0.2s;
}
.search__field:focus-within {
  border-color: var(--signal);
  box-shadow: 0 0 0 4px rgba(200, 242, 74, 0.12);
}
.search__icon { color: var(--ink-faint); flex-shrink: 0; }
#queryInput {
  flex: 1;
  background: none; border: none; outline: none;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  padding: 20px 0;
}
#queryInput::placeholder { color: var(--ink-faint); }
.search__go {
  position: relative;
  border: none; cursor: pointer;
  background: var(--signal);
  color: #10130a;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 16px;
  padding: 0 30px;
  border-radius: 14px;
  transition: 0.18s;
  min-width: 148px;
  display: grid; place-items: center;
}
.search__go:hover { background: #d6ff5b; transform: translateY(-1px); box-shadow: 0 12px 28px -12px rgba(200, 242, 74, 0.7); }
.search__go:active { transform: translateY(0); }
.search__go[data-loading] .search__go-label { visibility: hidden; }
.search__go-spinner {
  position: absolute;
  width: 18px; height: 18px;
  border: 2.5px solid rgba(16, 19, 10, 0.35);
  border-top-color: #10130a;
  border-radius: 50%;
  display: none;
  animation: spin 0.7s linear infinite;
}
.search__go[data-loading] .search__go-spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.search__controls {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-top: 16px; flex-wrap: wrap;
}
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 500;
  padding: 9px 15px;
  border-radius: 100px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink-dim);
  cursor: pointer;
  transition: 0.16s;
}
.chip:hover { color: var(--ink); border-color: #3a3a44; }
.chip svg { width: 15px; height: 15px; }
.chip[aria-selected="true"] {
  background: var(--signal);
  color: #10130a;
  border-color: var(--signal);
  font-weight: 600;
}
.limit { display: flex; align-items: center; gap: 9px; color: var(--ink-faint); font-size: 13px; font-family: var(--font-mono); }
.limit select {
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 9px; font-family: var(--font-mono); font-size: 13px; cursor: pointer;
}
.search__examples { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.ex {
  font-family: var(--font-mono); font-size: 12px;
  color: var(--ink-faint);
  border: 1px dashed var(--line); background: transparent;
  padding: 6px 11px; border-radius: 8px; cursor: pointer; transition: 0.15s;
}
.ex:hover { color: var(--signal); border-color: var(--signal); }

/* ---------------- Results ---------------- */
.results {
  position: relative; z-index: 2;
  max-width: 1240px;
  margin: 40px auto 0;
  padding: 0 clamp(18px, 5vw, 56px) 80px;
}
.results__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 22px; flex-wrap: wrap;
}
.results__head h2 { font-family: var(--font-display); font-weight: 500; font-size: 26px; margin: 0; letter-spacing: -0.02em; }
.results__head .count { font-family: var(--font-mono); font-size: 13px; color: var(--signal); }

/* Toolbar: view tabs + source filter */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-bottom: 18px;
}
.tabs { display: inline-flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 100px; padding: 4px; }
.tab {
  border: none; background: none; cursor: pointer;
  font-family: var(--font-body); font-size: 14px; font-weight: 600; color: var(--ink-dim);
  padding: 8px 18px; border-radius: 100px; transition: 0.16s;
}
.tab b { font-weight: 700; opacity: 0.7; margin-left: 2px; }
.tab[aria-selected="true"] { background: var(--signal); color: #10130a; }
.fchips { display: inline-flex; gap: 7px; flex-wrap: wrap; }
.fchip {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink-dim);
  font-family: var(--font-mono); font-size: 12px; padding: 7px 13px; border-radius: 100px;
  cursor: pointer; transition: 0.15s;
}
.fchip:hover { color: var(--ink); border-color: #3a3a44; }
.fchip[aria-selected="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
}

/* Lead card */
.card {
  position: relative;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  overflow: hidden;
  animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.card::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--src-color, var(--signal));
  opacity: 0.55;
}
.card:hover {
  transform: translateY(-4px);
  border-color: #37373f;
  box-shadow: var(--shadow);
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

.card__top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.avatar {
  width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0;
  object-fit: cover;
  display: grid; place-items: center;
  font-family: var(--font-mono); font-weight: 700; font-size: 15px;
  color: #10130a;
  background: linear-gradient(135deg, var(--src-color, var(--signal)), var(--amber));
}
.card__id { min-width: 0; flex: 1; }
.card__name { font-weight: 600; font-size: 16px; letter-spacing: -0.01em; display: flex; align-items: center; gap: 7px; }
.card__name .verified { color: var(--signal); }
.card__handle {
  font-family: var(--font-mono); font-size: 12px; color: var(--ink-faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px;
}
.src-badge {
  flex-shrink: 0;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 5px 9px; border-radius: 7px;
  color: var(--src-color, var(--signal));
  background: color-mix(in srgb, var(--src-color, var(--signal)) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--src-color, var(--signal)) 30%, transparent);
}
.card__headline { font-size: 13px; color: var(--ink-dim); margin: 0 0 10px; line-height: 1.4; }
.card__text {
  font-size: 14.5px; line-height: 1.5; color: var(--ink);
  margin: 0 0 16px;
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical;
  overflow: hidden;
}
.card__meta {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-faint);
  margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line-soft);
}
.card__meta .stat { display: inline-flex; align-items: center; gap: 5px; }
.card__actions { display: flex; gap: 9px; margin-top: 14px; }
.btn {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-body); font-weight: 600; font-size: 14px;
  padding: 11px 14px; border-radius: 10px;
  cursor: pointer; border: 1px solid transparent; transition: 0.16s;
}
.btn svg { width: 16px; height: 16px; }
.btn--dm { background: var(--signal); color: #10130a; }
.btn--dm:hover { background: #d6ff5b; box-shadow: 0 10px 22px -12px rgba(200, 242, 74, 0.8); }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--ink-dim); flex: 0 0 46px; }
.btn--ghost:hover { color: var(--ink); border-color: var(--signal); }
.btn--save { background: transparent; border-color: var(--line); color: var(--ink-dim); flex: 0 0 46px; }
.btn--save:hover { color: var(--amber); border-color: var(--amber); }
.btn--save.is-saved { color: #10130a; background: var(--amber); border-color: var(--amber); }
.btn--save.is-saved svg { fill: #10130a; }

/* ---------------- Empty / states ---------------- */
.empty {
  text-align: center; padding: 90px 20px; color: var(--ink-faint);
}
.empty__glyph { font-size: 54px; color: var(--line); margin-bottom: 18px; }
.empty p { font-size: 16px; line-height: 1.7; }
.empty p span { color: var(--ink-faint); font-size: 14px; }
.skeleton-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.sk {
  height: 250px; border-radius: var(--radius);
  background: linear-gradient(100deg, var(--panel) 30%, var(--panel-2) 50%, var(--panel) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border: 1px solid var(--line);
}
@keyframes shimmer { to { background-position: -200% 0; } }
.notice {
  text-align: center; padding: 70px 20px; color: var(--ink-dim);
}
.notice strong { color: var(--ink); }

/* ---------------- Footer ---------------- */
.footer {
  position: relative; z-index: 2;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  max-width: 1240px; margin: 0 auto; padding: 26px clamp(18px, 5vw, 56px);
  border-top: 1px solid var(--line-soft);
  font-family: var(--font-mono); font-size: 12px; color: var(--ink-faint);
}

/* ---------------- Drawer ---------------- */
.drawer { position: fixed; inset: 0; z-index: 60; }
.drawer[hidden] { display: none; }
.drawer__scrim { position: absolute; inset: 0; background: rgba(6, 6, 8, 0.7); backdrop-filter: blur(3px); animation: fade 0.25s; }
@keyframes fade { from { opacity: 0; } }
.drawer__panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(480px, 100%);
  background: var(--bg-2);
  border-left: 1px solid var(--line);
  box-shadow: -30px 0 60px -30px rgba(0, 0, 0, 0.8);
  padding: 26px;
  overflow-y: auto;
  animation: slidein 0.32s cubic-bezier(0.2, 0.7, 0.2, 1);
}
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } }
.drawer__close {
  position: absolute; top: 20px; right: 20px;
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--panel); border: 1px solid var(--line); color: var(--ink-dim);
  cursor: pointer; font-size: 14px; transition: 0.15s;
}
.drawer__close:hover { color: var(--ink); border-color: var(--signal); }

.d-head { display: flex; align-items: center; gap: 14px; margin: 6px 0 20px; }
.d-head .avatar { width: 56px; height: 56px; font-size: 18px; }
.d-name { font-family: var(--font-display); font-weight: 500; font-size: 22px; letter-spacing: -0.01em; }
.d-sub { font-family: var(--font-mono); font-size: 12px; color: var(--ink-faint); margin-top: 3px; }
.d-section { margin-bottom: 20px; }
.d-label { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 8px; }
.d-post {
  background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: 12px; padding: 15px; font-size: 14.5px; line-height: 1.6;
  white-space: pre-wrap; max-height: 220px; overflow-y: auto;
}
.d-facts { display: flex; flex-wrap: wrap; gap: 8px; }
.fact {
  font-family: var(--font-mono); font-size: 12px; color: var(--ink-dim);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px;
  display: inline-flex; gap: 7px; align-items: center;
}
.fact a { color: var(--signal); text-decoration: none; }

/* Channel selector */
.channels { display: flex; gap: 8px; flex-wrap: wrap; }
.channel {
  font-size: 13px; font-weight: 500; padding: 8px 13px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink-dim);
  cursor: pointer; transition: 0.15s; text-transform: capitalize;
}
.channel[aria-selected="true"] { background: var(--signal); color: #10130a; border-color: var(--signal); font-weight: 600; }
.channel:disabled { opacity: 0.35; cursor: not-allowed; }

.field-label { display: block; font-size: 13px; color: var(--ink-dim); margin: 14px 0 6px; }
.input, .textarea {
  width: 100%; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; color: var(--ink); font-family: var(--font-body); font-size: 14px;
  padding: 12px 14px; outline: none; transition: 0.15s; resize: vertical;
}
.input:focus, .textarea:focus { border-color: var(--signal); box-shadow: 0 0 0 3px rgba(200, 242, 74, 0.12); }
.textarea { min-height: 150px; line-height: 1.55; }
.d-actions { display: flex; gap: 10px; margin-top: 18px; }
.d-actions .btn { padding: 13px; font-size: 15px; }
.regen {
  background: none; border: none; color: var(--signal); font-family: var(--font-mono);
  font-size: 12px; cursor: pointer; padding: 0; margin-top: 8px;
}
.regen:hover { text-decoration: underline; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  z-index: 90;
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--ink); padding: 14px 20px; border-radius: 12px;
  font-size: 14px; box-shadow: var(--shadow);
  opacity: 0; transition: 0.3s; max-width: 90vw;
  display: flex; align-items: center; gap: 10px;
}
.toast[hidden] { display: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast__bar { width: 4px; align-self: stretch; border-radius: 4px; background: var(--signal); }
.toast.err .toast__bar { background: var(--rose); }

/* ---------------- Responsive ---------------- */
@media (max-width: 640px) {
  .topbar { padding: 14px 18px; }
  .ghost-btn { display: none; }
  .status-pills { display: none; }
  .search__row { flex-direction: column; }
  .search__go { padding: 16px; min-height: 54px; }
  .hero { padding-top: 44px; }
  .grid, .skeleton-grid { grid-template-columns: 1fr; }
  .drawer__panel { padding: 20px; }
}
@media (max-width: 400px) {
  .card__actions { flex-wrap: wrap; }
}
