:root {
  --base:    #303446;
  --mantle:  #292c3c;
  --crust:   #232634;
  --surface0:#414559;
  --surface1:#51576d;
  --surface2:#626880;
  --overlay0:#737994;
  --overlay1:#838ba7;
  --overlay2:#949cbb;
  --text:    #c6d0f5;
  --subtext0:#a5adce;
  --subtext1:#b5bfe2;
  --lavender:#babbf1;
  --blue:    #8caaee;
  --sapphire:#85c1dc;
  --sky:     #99d1db;
  --teal:    #81c8be;
  --green:   #a6d189;
  --yellow:  #e5c890;
  --peach:   #ef9f76;
  --maroon:  #ea999c;
  --red:     #e78284;
  --mauve:   #ca9ee6;
  --pink:    #f4b8e4;
  --flamingo:#eebebe;
  --rosewater:#f2d5cf;
}

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

body {
  background-color: var(--base);
  color: var(--text);
  font-family: 'Nunito', sans-serif;
  min-height: 100vh;
  padding: 1.25rem 1rem 4rem;
}

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

.page-wrap {
  position: relative;
  z-index: 1;
  max-width: 860px;
  margin: 0 auto;
  padding-top: 2.5rem;
}

.controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 180px;
}

.search-wrap input {
  width: 100%;
  background: var(--mantle);
  border: 1px solid var(--surface1);
  border-radius: 8px;
  padding: 0.55rem 0.9rem 0.55rem 2.4rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-wrap input::placeholder { color: var(--overlay0); }
.search-wrap input:focus { border-color: var(--lavender); }

.search-wrap .search-icon {
  position: absolute;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--overlay0);
  font-size: 18px;
  pointer-events: none;
  user-select: none;
}

.sort-btn {
  background: var(--mantle);
  border: 1px solid var(--surface1);
  border-radius: 8px;
  padding: 0.55rem 1rem;
  color: var(--subtext1);
  font-family: 'Playfair Display', serif;
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  white-space: nowrap;
}

.sort-btn:hover, .sort-btn.active {
  border-color: var(--lavender);
  color: var(--lavender);
  background: var(--surface0);
}

.reset-btn {
  background: transparent;
  border: 1px solid var(--surface1);
  border-radius: 8px;
  padding: 0.55rem 1rem;
  color: var(--maroon);
  font-family: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.reset-btn:hover {
  border-color: var(--red);
  background: rgba(231,130,132,0.08);
}

.stats {
  text-align: center;
  font-size: 0.78rem;
  color: var(--overlay0);
  margin-bottom: 1.25rem;
  font-family: 'Playfair Display', serif;
}

.stats span { color: var(--green); }

#torrent-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.torrent-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-radius: 10px;
  padding: 0.6rem 1rem;
  transition: border-color 0.15s, background 0.15s, opacity 0.2s;
  animation: rowIn 0.3s ease both;
  position: relative;
  overflow: hidden;
}

.torrent-row::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 120px;
  /* background: linear-gradient(to right, rgba(202,158,230,0.12), transparent); */
  border-radius: 10px 0 0 10px;
  pointer-events: none;
}

@keyframes rowIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.torrent-row:hover {
  border-color: var(--surface1);
  background: var(--surface0);
}

.torrent-row.voted-up   { border-color: rgba(166,209,137,0.4); }
.torrent-row.voted-down { border-color: rgba(231,130,132,0.3); }

.vote-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.vote-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 5px;
  color: var(--overlay1);
  font-size: 0.8rem;
  line-height: 1;
  transition: color 0.15s, background 0.15s, transform 0.1s;
}


.vote-btn.up:hover   { color: var(--green); background: rgba(166,209,137,0.12); }
.vote-btn.down:hover { color: var(--red);   background: rgba(231,130,132,0.12); }
.vote-btn.up.active  { color: var(--green); }
.vote-btn.down.active{ color: var(--red);   }
.vote-btn:disabled   { opacity: 0.35; transform: none !important; }

.score {
  font-family: 'Playfair Display', serif;
  font-size: 0.78rem;
  font-weight: 700;
  min-width: 2.6rem;
  text-align: center;
  color: var(--subtext0);
  flex-shrink: 0;
}
.score.positive { color: var(--green); }
.score.negative { color: var(--red);   }

.bar-wrap {
  width: 54px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  margin-bottom: -16px;
}

.bar-track {
  background: var(--surface0);
  border-radius: 4px;
  height: 5px;
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}
.bar-fill.pos { background: var(--green); }
.bar-fill.neg { background: var(--red);   }

.pct-label {
  font-family: 'Playfair Display', serif;
  font-size: 0.65rem;
  color: var(--overlay0);
  text-align: center;
  line-height: 1;
  margin-top: 2px;
}

.torrent-name {
  flex: 1;
  font-size: 0.83rem;
  color: var(--text);
  line-height: 1.35;
  word-break: break-word;
}

.voted-badge {
  font-family: 'Playfair Display', serif;
  font-size: 0.62rem;
  padding: 2px 6px;
  border-radius: 20px;
  flex-shrink: 0;
}
.voted-badge.up   { background: rgba(166,209,137,0.15); color: var(--green); }
.voted-badge.down { background: rgba(231,130,132,0.12); color: var(--red); }

#empty-msg {
  text-align: center;
  color: var(--overlay0);
  font-size: 0.85rem;
  padding: 3rem;
  display: none;
}

#scrolltop {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--surface0);
  border: 1px solid var(--surface1);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  cursor: pointer;
  color: var(--subtext1);
  font-size: 1rem;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
#scrolltop.visible { opacity: 1; pointer-events: all; }
#scrolltop:hover { color: var(--lavender); border-color: var(--lavender); }

/* torrent stats */
.torrent-stats {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-shrink: 0;
  margin-left: auto;
}

.stat {
  font-family: 'Playfair Display', serif;
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 6px;
  white-space: nowrap;
}

.stat.size     { background: rgba(186,187,241,0.1); color: var(--lavender); }
.stat.seeders  { background: rgba(166,209,137,0.1); color: var(--green); }
.stat.leechers { background: rgba(231,130,132,0.1); color: var(--red); }
