:root {
  --bg: #0e1116;
  --bg-elev: #171b22;
  --bg-hover: #1f242d;
  --border: #262c36;
  --text: #e6e9ef;
  --text-dim: #9aa4b2;
  --accent: #4c8dff;
  --radius: 12px;
  --maxw: 1100px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

:root[data-theme="light"] {
  --bg: #f6f7f9;
  --bg-elev: #ffffff;
  --bg-hover: #eef1f5;
  --border: #e2e6ec;
  --text: #1a1f27;
  --text-dim: #5b6572;
  --accent: #2f6fe0;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 96px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Cabeçalho fixo */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.brand-mark { font-size: 20px; }
.brand-name { letter-spacing: -0.01em; }

.search-wrap { flex: 1; display: flex; justify-content: center; }

#search {
  width: 100%;
  max-width: 460px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

.theme-btn {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  width: 38px; height: 38px;
  border-radius: 10px;
  font-size: 16px;
  cursor: pointer;
  transition: background .15s;
}
.theme-btn:hover { background: var(--bg-hover); }

/* Barra de secções */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: var(--maxw);
  margin: 18px auto 4px;
  padding: 0 20px;
}
.chips a {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13px;
  transition: color .15s, border-color .15s, background .15s;
}
.chips a:hover { color: var(--text); border-color: var(--accent); background: var(--bg-elev); }

/* Conteúdo */
main { max-width: var(--maxw); margin: 0 auto; padding: 16px 20px 60px; }

.cat { margin-top: 30px; scroll-margin-top: 92px; }
.cat-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-dim); font-weight: 700; margin: 0 0 12px;
}
.cat-count {
  font-size: 11px; color: var(--text-dim);
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 999px; padding: 1px 7px; letter-spacing: 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.src {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 13px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: border-color .15s, background .15s, transform .05s;
}
.src:hover { border-color: var(--accent); background: var(--bg-hover); }
.src:active { transform: translateY(1px); }

.src-icon {
  width: 20px; height: 20px; border-radius: 5px; flex-shrink: 0;
  background: var(--bg-hover);
}
.src-body { display: flex; flex-direction: column; min-width: 0; }
.src-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.src-desc { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.empty { text-align: center; color: var(--text-dim); margin-top: 40px; }

.foot {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  color: var(--text-dim); font-size: 12px;
  border-top: 1px solid var(--border);
}

/* Estado da pesquisa: esconder o que não corresponde */
.src.is-hidden, .cat.is-hidden { display: none; }

@media (max-width: 560px) {
  .brand-name { display: none; }
  .top { gap: 10px; padding: 10px 14px; }
  main, .chips, .foot { padding-left: 14px; padding-right: 14px; }
}
