:root {
  --bg: #0d1117;
  --panel: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #1f6feb;
  --accent2: #238636;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

header {
  display: flex; align-items: center; flex-wrap: wrap; gap: 14px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: rgba(13,17,23,.9); backdrop-filter: blur(8px); z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.brand svg { flex-shrink: 0; }
.brand h1 { font-size: 18px; font-weight: 700; }
.brand .tag { color: var(--muted); font-size: 12px; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button, .rankbar button {
  padding: 7px 14px; border-radius: 8px; border: 1px solid transparent;
  background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all .15s;
}
.tabs button:hover { color: var(--text); background: var(--panel); }
.tabs button.active { color: #fff; background: var(--panel); border-color: var(--border); }
.rankbar button.active, .rankbar button:hover { color: #fff; border-color: var(--accent); }

.search { margin-left: auto; }
.search form { display: flex; gap: 8px; }
.search input {
  width: 340px; max-width: 50vw;
  padding: 9px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); font-size: 13px; outline: none;
}
.search input:focus { border-color: var(--accent); }
.search button {
  padding: 9px 18px; border-radius: 8px; border: none; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 600;
}
.search button:hover { background: #388bfd; }

main { padding: 22px 24px 60px; max-width: 1600px; margin: 0 auto; }

.hero { margin-bottom: 20px; }
.hero h2 { font-size: 24px; font-weight: 700; }
.hero p { color: var(--muted); font-size: 14px; margin-top: 6px; max-width: 640px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chipsBtn {
  padding: 6px 12px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); font-size: 12px; cursor: pointer;
}
.chipsBtn:hover { border-color: var(--accent); }

.rankbar { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }

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

.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; cursor: pointer; transition: transform .15s, border-color .15s;
  position: relative;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); }
.card .thumb { width: 100%; aspect-ratio: 16/9; object-fit: cover; background: linear-gradient(135deg,#161b22,#0d1117); display: block; }
.card .thumb.fallback {
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 13px; background: linear-gradient(135deg,#21262d,#161b22);
}
.card .body { padding: 12px 14px; }
.card .name { font-size: 14px; font-weight: 600; word-break: break-all; }
.card .desc {
  color: var(--muted); font-size: 13px; margin-top: 4px; min-height: 18px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card .meta { display: flex; align-items: center; gap: 12px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.card .meta2 { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; }
.card .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.card .when { color: var(--muted); font-size: 11px; }
.rankNum { position: absolute; top: 10px; left: 10px; background: rgba(0,0,0,.65); color: #fff; font-weight: 700; padding: 3px 8px; border-radius: 6px; font-size: 12px; }

.langgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.langbtn {
  display: flex; align-items: center; gap: 10px; padding: 16px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); cursor: pointer; text-align: left; transition: all .15s;
}
.langbtn:hover { border-color: var(--accent); transform: translateY(-2px); }
.lg-icon { font-size: 22px; }
.lg-name { font-weight: 600; font-size: 15px; }

.sugest { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.sugestBtn {
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); font-size: 13px; cursor: pointer;
}
.sugestBtn:hover { border-color: var(--accent); }

.empty { color: var(--muted); text-align: center; padding: 40px; }

#status { text-align: center; color: var(--muted); padding: 40px; font-size: 14px; }
#status:empty { display: none; padding: 0; }
#status.error { color: #f85149; }
/* If results already painted, never leave a stale "Cargando…" under the grid */
main:has(#view:not(:empty)) #status:not(.error) { display: none !important; padding: 0; }

.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.92); display: none;
  align-items: center; justify-content: center; z-index: 50; padding: 24px;
}
.lightbox.open { display: flex; }
.lightbox .close { position: absolute; top: 16px; right: 24px; font-size: 36px; color: var(--muted); cursor: pointer; }
.lightbox .close:hover { color: #fff; }
.lb-inner { max-width: 1100px; width: 100%; display: flex; flex-direction: column; align-items: center; }
.lb-inner img { max-width: 100%; max-height: 60vh; border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,.6); }
.lb-meta { margin-top: 20px; text-align: center; max-width: 760px; width: 100%; }
.lb-meta h2 { font-size: 20px; }
.lb-meta p { color: var(--muted); margin-top: 6px; font-size: 14px; }
.lb-badges { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.lb-badges .badge {
  padding: 5px 12px; border-radius: 20px; background: var(--panel);
  border: 1px solid var(--border); font-size: 12px; color: var(--text);
}
a.live {
  display: inline-block; margin-top: 14px; color: var(--accent); text-decoration: none;
  font-weight: 600; font-size: 14px;
}
a.live:hover { text-decoration: underline; }

@media (max-width: 760px) {
  .search { margin-left: 0; width: 100%; }
  .search form, .search input { width: 100%; }
}