*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #080808;
  --bg2:       #111111;
  --bg3:       #181818;
  --border:    #242424;
  --red:       #e03030;
  --red-dim:   #b52525;
  --red-glow:  rgba(224,48,48,0.12);
  --text:      #e2e2e2;
  --text-dim:  #7a7a7a;
  --text-faint:#3a3a3a;
  --mono:      'JetBrains Mono', monospace;
  --sans:      'Manrope', sans-serif;
  --r:         10px;
  --r-sm:      6px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  line-height: 1.5;
}

.noise {
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none; z-index: 0; opacity: 0.35;
}

header {
  padding: 2rem 2.5rem 1.6rem;
  border-bottom: 1px solid var(--border);
  position: relative; z-index: 1;
}

.logo {
  display: flex; align-items: center; gap: 0.55rem;
  font-family: var(--sans);
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.logo-icon { color: var(--red); font-size: 1.2rem; line-height: 1; }
.logo-text em { color: var(--red); font-style: normal; }

.tagline {
  margin-top: 0.35rem;
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-family: var(--mono);
}

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  position: relative; z-index: 1;
}

/* SEARCH */
.search-section { margin-bottom: 2rem; }

.search-box {
  display: flex; align-items: center;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-box:focus-within {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-glow);
}

.search-prefix {
  padding: 0 0.2rem 0 1.1rem;
  color: var(--red);
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 600;
  user-select: none;
}

#usernameInput {
  flex: 1;
  background: transparent;
  border: none; outline: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 1rem;
  padding: 0.9rem 0.7rem;
  caret-color: var(--red);
}
#usernameInput::placeholder { color: var(--text-faint); }

#searchBtn {
  background: var(--red);
  border: none;
  color: #fff;
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0 1.4rem;
  height: 100%;
  cursor: pointer;
  display: flex; align-items: center; gap: 0.4rem;
  transition: background 0.15s;
  white-space: nowrap;
  min-height: 50px;
}
#searchBtn:hover { background: var(--red-dim); }
#searchBtn:disabled { background: #2a2a2a; color: var(--text-faint); cursor: not-allowed; }
.btn-icon { font-size: 1rem; }

.search-options {
  display: flex; gap: 1.4rem;
  margin-top: 0.8rem;
  font-size: 0.73rem;
  color: var(--text-dim);
  font-family: var(--mono);
}
.search-options label {
  display: flex; align-items: center; gap: 0.4rem;
  cursor: pointer; user-select: none;
}
.search-options input[type=checkbox] {
  accent-color: var(--red);
  width: 13px; height: 13px;
}

/* STATUS */
.status-section { margin-bottom: 1.5rem; }

.status-bar {
  display: flex; align-items: center; gap: 0.65rem;
  font-size: 0.73rem;
  color: var(--text-dim);
  font-family: var(--mono);
  margin-bottom: 0.5rem;
}

.status-indicator {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--red);
  animation: pulse 1.3s infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.35; transform: scale(0.65); }
}

.progress-wrap {
  height: 2px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--red);
  width: 0%;
  transition: width 0.4s ease;
  border-radius: 99px;
}

/* SUMMARY STATS */
.summary-section {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1rem 1rem 0.9rem;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}
.stat-card:hover { border-color: #333; background: var(--bg3); }

.stat-num {
  display: block;
  font-family: var(--sans);
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--red);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.stat-label {
  font-size: 0.62rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 0.25rem;
  display: block;
  font-family: var(--mono);
}

/* SUBREDDIT BREAKDOWN */
.sub-breakdown {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.2rem 1.4rem;
  margin-bottom: 1.5rem;
}

.section-title {
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  margin-bottom: 1rem;
  text-transform: uppercase;
}

.sub-list {
  display: flex; flex-wrap: wrap; gap: 0.45rem;
}

.sub-pill {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 0.28rem 0.75rem;
  font-size: 0.72rem;
  font-family: var(--mono);
  cursor: pointer;
  transition: all 0.15s;
  display: flex; align-items: center; gap: 0.45rem;
  white-space: nowrap;
  color: var(--text-dim);
}
.sub-pill:hover { border-color: var(--red); color: var(--text); }
.sub-pill .pill-count {
  background: var(--red);
  color: #fff;
  font-size: 0.6rem;
  padding: 1px 6px;
  border-radius: 99px;
  font-weight: 700;
}

/* RESULTS */
.results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.filter-bar {
  display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap;
}

.filter-btn {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 0.3rem 0.8rem;
  cursor: pointer;
  border-radius: 99px;
  transition: all 0.15s;
}
.filter-btn:hover { border-color: #444; color: var(--text); }
.filter-btn.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

#subFilter, #sortFilter {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 0.3rem 0.65rem;
  border-radius: var(--r-sm);
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}
#subFilter:focus, #sortFilter:focus { border-color: var(--red); }

/* FEED */
.feed-container { display: flex; flex-direction: column; gap: 0.55rem; }

.feed-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: var(--r);
  padding: 0.95rem 1.1rem;
  transition: border-color 0.15s, background 0.15s;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.feed-item:hover { background: var(--bg3); }
.feed-item.type-post    { border-left-color: var(--red); }
.feed-item.type-comment { border-left-color: #2c5c2c; }

.item-meta {
  display: flex; align-items: center; gap: 0.55rem;
  font-size: 0.67rem;
  color: var(--text-dim);
  margin-bottom: 0.45rem;
  flex-wrap: wrap;
  font-family: var(--mono);
}

.item-type {
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 99px;
}
.type-post .item-type    { background: rgba(224,48,48,0.12); color: var(--red); }
.type-comment .item-type { background: rgba(76,175,80,0.1);  color: #4caf50; }

.item-source.src-arctic  { border-color: #3a6ea8; color: #5b9bd5; opacity: 0.7; }
.item-source.src-pullpush { border-color: #6a3a8a; color: #a07ac8; opacity: 0.7; }
.item-source.src-reddit  { border-color: #555; opacity: 0.5; }

.item-sub {
  color: var(--red);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s;
}
.item-sub:hover { opacity: 0.7; }

.item-date { color: var(--text-faint); }

.item-source {
  font-size: 0.58rem;
  border: 1px solid var(--text-faint);
  padding: 1px 6px;
  border-radius: 99px;
  opacity: 0.45;
  color: var(--text-faint);
}

.item-score {
  margin-left: auto;
  display: flex; align-items: center; gap: 0.25rem;
  color: var(--text-dim); font-size: 0.68rem;
}
.score-up { color: var(--red); }

.item-title {
  font-family: var(--sans);
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  line-height: 1.45;
}
.item-title a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s;
}
.item-title a:hover { color: var(--red); }

.item-context {
  font-size: 0.67rem;
  color: var(--text-faint);
  font-family: var(--mono);
  margin-bottom: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-body {
  font-size: 0.78rem;
  color: #c0c0c0;
  line-height: 1.65;
  max-height: 4.5em;
  overflow: hidden;
  position: relative;
  font-family: var(--mono);
  white-space: pre-wrap;
}
.item-body.expanded { max-height: none; }
.item-body::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 28px;
  background: linear-gradient(transparent, var(--bg2));
  pointer-events: none;
}
.item-body.expanded::after { display: none; }

.item-actions {
  margin-top: 0.5rem;
  display: flex; gap: 0.9rem;
}
.item-action {
  font-size: 0.66rem;
  color: var(--text-faint);
  cursor: pointer;
  background: none; border: none;
  font-family: var(--mono);
  padding: 0;
  transition: color 0.15s;
  text-decoration: none;
}
.item-action:hover { color: var(--red); }

/* IMAGES */
.item-images {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.6rem 0;
}

.item-img {
  width: 160px;
  height: 120px;
  object-fit: cover;
  border-radius: var(--r-sm);
  cursor: zoom-in;
  border: 1px solid var(--border);
  transition: opacity 0.15s, border-color 0.15s, transform 0.15s;
  background: var(--bg3);
}
.item-img:hover {
  opacity: 0.9;
  border-color: var(--red);
  transform: scale(1.02);
}

/* LIGHTBOX */
#lightbox {
  display: none;
  position: fixed; inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
#lightbox.open { display: flex; }

.lb-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.92);
  cursor: zoom-out;
}

.lb-img {
  position: relative; z-index: 1;
  max-width: 90vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: var(--r);
  border: 1px solid var(--border);
  box-shadow: 0 0 60px rgba(0,0,0,0.8);
}

.lb-close {
  position: absolute;
  top: 1.2rem; right: 1.2rem;
  z-index: 2;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 1rem;
  width: 36px; height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.lb-close:hover { border-color: var(--red); color: var(--red); }

/* LOAD MORE */
.load-more { text-align: center; margin-top: 1.5rem; }
.load-more button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.6rem 2rem;
  cursor: pointer;
  border-radius: var(--r);
  transition: all 0.15s;
}
.load-more button:hover { border-color: var(--red); color: var(--red); }

/* ERROR */
.error-box {
  background: var(--bg2);
  border: 1px solid #3a1515;
  border-radius: var(--r);
  padding: 2.5rem 2rem;
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
}
.error-icon { font-size: 1.8rem; color: var(--red); }
.error-box p {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-family: var(--mono);
  max-width: 420px;
  line-height: 1.65;
}
.error-box button {
  background: var(--red);
  border: none; color: #fff;
  font-family: var(--mono);
  font-size: 0.73rem;
  padding: 0.55rem 1.5rem;
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: background 0.15s;
}
.error-box button:hover { background: var(--red-dim); }

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

footer {
  position: relative; z-index: 1;
  text-align: center;
  padding: 1.4rem;
  font-size: 0.82rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  letter-spacing: 0.04em;
  font-family: var(--mono);
}

.footer-credit {
  color: var(--red);
  text-decoration: none;
  display: inline-block;
  animation: dance 1.6s ease-in-out infinite;
  font-weight: 600;
}
.footer-credit:hover {
  animation: danceFast 0.5s ease-in-out infinite;
}

@keyframes dance {
  0%   { transform: translateY(0)    rotate(0deg)   scale(1); }
  20%  { transform: translateY(-4px) rotate(-4deg)  scale(1.08); }
  40%  { transform: translateY(2px)  rotate(3deg)   scale(0.96); }
  60%  { transform: translateY(-3px) rotate(-2deg)  scale(1.05); }
  80%  { transform: translateY(1px)  rotate(2deg)   scale(0.98); }
  100% { transform: translateY(0)    rotate(0deg)   scale(1); }
}

@keyframes danceFast {
  0%   { transform: translateY(0)    rotate(0deg)  scale(1); }
  25%  { transform: translateY(-5px) rotate(-6deg) scale(1.12); }
  75%  { transform: translateY(3px)  rotate(5deg)  scale(0.93); }
  100% { transform: translateY(0)    rotate(0deg)  scale(1); }
}

/* RESPONSIVE */
@media (max-width: 600px) {
  header { padding: 1.5rem 1.25rem 1.2rem; }
  .summary-section { grid-template-columns: repeat(2, 1fr); }
  .results-toolbar { flex-direction: column; align-items: flex-start; }
  .search-options { flex-wrap: wrap; gap: 0.75rem; }
}
