*{box-sizing:border-box}

:root{
  --bg:#f5f7fa;
  --card:#fff;
  --card-border:#e2e6eb;
  --text:#20242a;
  --muted:#7a818b;
  --accent:#2563eb;
  --accent-hover:#1d4ed8;
  --border:#d7dce2;
  --danger:#ef4444;
  --success:#22c55e;
  --ad-bg:#fafbfc;
}

body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Microsoft YaHei","Noto Sans SC",sans-serif;
  line-height:1.5;
}

.page-wrapper{
  display:flex;
  min-height:100vh;
  justify-content:center;
  gap:0;
}

.side-ad{
  width:160px;
  flex-shrink:0;
  padding:20px 10px;
  background:var(--ad-bg);
  border:1px solid var(--card-border);
  min-height:100vh;
  overflow:auto;
  font-size:13px;
  color:var(--muted);
}

.side-ad:empty{
  display:none;
}

.side-ad img{
  max-width:100%;
  height:auto;
  display:block;
  margin:0 auto 10px;
}

.left-ad{
  border-right:none;
  border-radius:0 0 0 0;
}

.right-ad{
  border-left:none;
}

.container{
  max-width:1100px;
  width:100%;
  margin:0 auto;
  padding:0 18px 50px;
  flex:1;
  min-width:0;
}

/* Top bar for ad coop */
.top-bar{
  display:flex;
  justify-content:flex-end;
  padding:12px 0 0;
  min-height:28px;
}
.ad-coop{
  font-size:13px;
  color:var(--muted);
}
.ad-coop a{
  color:var(--accent);
  text-decoration:none;
}
.ad-coop a:hover{
  text-decoration:underline;
}

/* Hero / Search */
.hero{
  padding:8vh 0 42px;
  text-align:center;
}
.hero h1{
  font-size:42px;
  margin:0 0 8px;
  font-weight:700;
  letter-spacing:-.5px;
}
.hero p{
  margin:0 0 28px;
  color:var(--muted);
  font-size:15px;
}
.search{
  display:flex;
  max-width:760px;
  margin:auto;
  background:var(--card);
  border:1px solid var(--border);
  border-radius:12px;
  overflow:hidden;
  box-shadow:0 5px 20px #0000000b;
  transition:border-color .2s,box-shadow .2s;
}
.search:focus-within{
  border-color:var(--accent);
  box-shadow:0 5px 24px rgba(37,99,235,.12);
}
.search input{
  flex:1;
  min-width:0;
  border:0;
  outline:0;
  padding:17px 18px;
  font-size:17px;
  background:transparent;
}
.search button{
  border:0;
  background:var(--accent);
  color:white;
  padding:0 28px;
  font-size:16px;
  cursor:pointer;
  transition:background .15s;
}
.search button:hover:not(:disabled){
  background:var(--accent-hover);
}
.search button:disabled{
  opacity:.6;
  cursor:not-allowed;
}

/* Toolbar */
.toolbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:15px;
  margin:0 0 14px;
}
.sort{
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
}
.sort select,.sort button,.pager button{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:7px;
  padding:8px 10px;
  cursor:pointer;
  font-size:13px;
  color:var(--text);
}
.sort button{
  min-width:85px;
  transition:background .15s;
}
.sort button:hover{
  background:#f0f2f5;
}
.limit-label{
  font-size:13px;
  color:var(--muted);
}

/* Status & Skeleton */
.status{
  min-height:24px;
  color:var(--muted);
  margin:10px 0;
  text-align:center;
  font-size:14px;
}
.skeleton{
  display:flex;
  flex-direction:column;
  gap:10px;
}
.skeleton-card{
  height:120px;
  background:linear-gradient(90deg,#e8eaed 25%,#f0f2f5 50%,#e8eaed 75%);
  background-size:200% 100%;
  animation:shimmer 1.5s infinite;
  border-radius:10px;
}
@keyframes shimmer{
  0%{background-position:200% 0}
  100%{background-position:-200% 0}
}

/* Results */
.results{
  display:flex;
  flex-direction:column;
  gap:10px;
}
.card{
  background:var(--card);
  border:1px solid var(--card-border);
  border-radius:10px;
  padding:17px 18px;
  transition:box-shadow .2s,border-color .2s;
}
.card:hover{
  box-shadow:0 2px 12px #0000000a;
  border-color:#d0d5dc;
}
.title{
  font-size:16px;
  font-weight:600;
  line-height:1.45;
  word-break:break-all;
  margin-bottom:12px;
  cursor:default;
}
.meta{
  display:flex;
  flex-wrap:wrap;
  gap:8px 20px;
  color:var(--muted);
  font-size:13px;
}
.meta-item{
  display:flex;
  gap:5px;
}
.meta-label{
  color:var(--muted);
}
.meta-value{
  color:var(--text);
  font-weight:500;
}
.seeders-zero{
  color:var(--danger);
  opacity:.7;
}
.card-actions{
  display:flex;
  gap:10px;
  margin-top:13px;
  align-items:center;
}
.magnet-btn{
  display:inline-block;
  color:var(--accent);
  text-decoration:none;
  font-size:13px;
  font-weight:500;
}
.magnet-btn:hover{
  text-decoration:underline;
}
.copy-btn{
  border:1px solid var(--border);
  background:var(--card);
  border-radius:7px;
  padding:6px 14px;
  cursor:pointer;
  font-size:13px;
  color:var(--muted);
  transition:all .15s;
}
.copy-btn:hover{
  border-color:var(--accent);
  color:var(--accent);
  background:#f5f8ff;
}
.copy-btn.copied{
  border-color:var(--success);
  color:var(--success);
  background:#f0fdf4;
}

/* Pager */
.pager{
  display:flex;
  justify-content:center;
  align-items:center;
  gap:16px;
  margin-top:22px;
}
.pager span{
  font-size:14px;
  color:var(--muted);
  min-width:120px;
  text-align:center;
}
.pager button{
  transition:background .15s;
}
.pager button:hover:not(:disabled){
  background:#f0f2f5;
}
.pager button:disabled{
  opacity:.4;
  cursor:not-allowed;
}

.hidden{display:none}

/* Responsive */
@media(max-width:900px){
  .side-ad{
    display:none !important;
  }
}
@media(max-width:650px){
  .hero{padding-top:5vh}
  .hero h1{font-size:34px}
  .search button{padding:0 18px}
  .toolbar{align-items:flex-start;flex-direction:column}
  .card{padding:14px}
  .meta{gap:7px 14px}
  .card-actions{flex-direction:column;align-items:flex-start}
  .copy-btn{width:100%;text-align:center}
  .top-bar{justify-content:center}
}
