/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0d0d0f;
  --surface:  #16161a;
  --border:   #252530;
  --border2:  #2e2e3a;
  --text:     #e2e2ec;
  --muted:    #666680;
  --accent:   #7c6af7;
  --accent-h: #9b8bff;
  --green:    #4ade80;
  --reddit:   #ff5722;
  --hn:       #ff7043;
  --web:      #42a5f5;
  --ai:       #ab7cfa;
  --error:    #f87171;
  --radius:   12px;
  --radius-s: 8px;
}

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent-h); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ── */
.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

/* ── Header ── */
header {
  text-align: center;
  padding: 64px 0 40px;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 14px;
}

.globe { font-size: 28px; }

.brand {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #fff;
}

.tagline {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 20px;
}

.platform-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.pill {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid;
  opacity: 0.7;
}
.pill-reddit { color: var(--reddit); border-color: var(--reddit); }
.pill-hn     { color: var(--hn);     border-color: var(--hn); }
.pill-web    { color: var(--web);    border-color: var(--web); }
.pill-ai     { color: var(--ai);     border-color: var(--ai); }

/* ── Search form ── */
#searchForm { margin-bottom: 24px; }

.search-row {
  display: flex;
  gap: 10px;
  background: var(--surface);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius);
  padding: 6px 6px 6px 18px;
  transition: border-color 0.15s;
}
.search-row:focus-within { border-color: var(--accent); }

#queryInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-width: 0;
}
#queryInput::placeholder { color: var(--muted); }

#submitBtn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-s);
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, opacity 0.15s;
  flex-shrink: 0;
}
#submitBtn:hover { background: var(--accent-h); }
#submitBtn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Status bar ── */
.status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 20px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Source stats ── */
.source-stats {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 20px;
}
.stat { display: flex; align-items: center; gap: 5px; }
.stat-sep { color: var(--border2); }
.stat-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-hn  { background: var(--hn); }
.dot-ai  { background: var(--ai); }

/* ── Results ── */
.results {
  background: var(--surface);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius);
  overflow: hidden;
}

.result-content {
  padding: 28px 32px;
  line-height: 1.75;
  font-size: 15px;
  overflow-wrap: break-word;
}

/* Markdown styles inside result */
.result-content p { margin-bottom: 1em; }
.result-content p:last-child { margin-bottom: 0; }
.result-content strong { color: #fff; font-weight: 600; }
.result-content em { color: var(--muted); }
.result-content a { color: var(--accent-h); }
.result-content a:hover { color: #fff; }
.result-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}
.result-content ul, .result-content ol {
  padding-left: 22px;
  margin-bottom: 1em;
}
.result-content li { margin-bottom: 4px; }
.result-content code {
  background: rgba(124, 106, 247, 0.12);
  color: var(--accent-h);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}
.result-content pre {
  background: #0a0a0c;
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 14px 18px;
  overflow-x: auto;
  margin-bottom: 1em;
}
.result-content pre code {
  background: none;
  padding: 0;
  color: var(--text);
}

/* Badge line (first line of output) */
.result-content p:first-child {
  font-size: 12px;
  color: var(--muted);
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.result-actions {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--muted);
  border-radius: var(--radius-s);
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--text);
}

/* ── Error ── */
.error-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.25);
  border-radius: var(--radius-s);
  padding: 14px 18px;
  font-size: 14px;
  color: var(--error);
}
.error-icon { flex-shrink: 0; }

/* ── Footer ── */
footer {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding-top: 48px;
}

/* ── Lang toggle ── */
.lang-toggle {
  position: fixed;
  top: 16px;
  right: 20px;
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--muted);
  border-radius: var(--radius-s);
  padding: 5px 13px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  z-index: 100;
}
.lang-toggle:hover {
  border-color: var(--accent);
  color: var(--text);
}

/* ── Utility ── */
.hidden { display: none !important; }

/* ── Responsive ── */
@media (max-width: 520px) {
  header { padding: 40px 0 28px; }
  .brand { font-size: 22px; }
  .search-row { padding: 6px 6px 6px 14px; }
  #submitBtn { padding: 9px 13px; }
  .result-content { padding: 20px 18px; }
}
